Home Forums WPF controls Xceed DataGrid for WPF Ignoring property while binding

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25269 |

    Hi,
    I have the grid set up to autocreate columns. Is there a way that i can specify to exclude binding for one of the properties exposed by my source object?

    Thanks.

    Imported from legacy forums. Posted by abatti (had 2248 views)

    Xceed Support
    Member
    Post count: 5658

    The simplest way of doing something like that is as follows:

    <xcdg:DataGridControl>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”myFieldName” Visible=”False” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    This indicates to the DataGridControl to hide cells for the “myFieldName” property of the Data Object.

    If you really want the property to “not be bound at all”, then the process has slightly more verbose:

    <Window.Resources>
    <DataGridCollectionViewSource x:Key=”myCVS”>
    <DataGridCollectionViewSource.ItemProperties>
    <DataGridItemProperty Name=”myOtherField” />
    <!– In this approach, you have to specify all the properties you WANT to see and OMIT the ones you don’t want to see –>
    </DataGridCollectionViewSource.ItemProperties>
    </DataGridCollectionViewSource>
    </Window.Resources>

    <DataGridControl ItemsSource=”{Binding Source={StaticResource myCVS}}” />

    Imported from legacy forums. Posted by Marcus [Xceed] (had 272 views)

    User (Old forums)
    Member
    Post count: 23064

    Marcus,
    Thanks for the reply. The problem i have is that at compile time i don’t know the type of object in my model and i don’t want to define in the xaml the list of columns for every possible scenario i have. Was wondering if by annotating the class property with an attribute( i.e [IgnoreBinding]) my property won’t be bound to the grid.

    Regards,

    Imported from legacy forums. Posted by abatti (had 3311 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.