Home Forums WPF controls Xceed DataGrid for WPF Binding to a property for data in a CellContentTemplate

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

    I have a DataGridControl whose ItemsSource is an instance of System.Data.DataView.

    Now in a CellContentTemplate, I want to bind a custom control’s property to the corresponding System.Data.DataRow. This custom control needs to ‘know’ about other information in the DataRow.

    I cannot figure out how to do this, any help would be appreciated. Below is a code snippet of what I am trying to accomplish:

    <!– code … –>

    <xcdg:DataGridControl Name=”dataGrid” AutoCreateColumns=”False”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”RowStatus” Title=”Commands”>
    <xcdg:Column.CellContentTemplate>
    <DataTemplate>

    <!–
    is there a way to extract the datarow using binding?
    –>

    <ctl:RowStatusButtonsXceed DataRow=”{Binding ???}” />

    </DataTemplate>
    </xcdg:Column.CellContentTemplate>
    </xcdg:Column>
    <xcdg:Column FieldName=”RowStatus” Title=”Row Status” />
    <xcdg:Column FieldName=”NameType” Title=”Name Type” />
    <xcdg:Column FieldName=”FirstName” Title=”First Name” />
    <xcdg:Column FieldName=”Middle” Title=”Middle Name” />
    <xcdg:Column FieldName=”Surname” Title=”Surname” />
    <xcdg:Column FieldName=”Suffix” Title=”Suffix” />
    <xcdg:Column FieldName=”Title” Title=”Title” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    <!– more code … –>

    Imported from legacy forums. Posted by bbqfrito (had 2414 views)

    Xceed Support
    Member
    Post count: 5658

    What I suggest is binding the Column’s Content to the whole Data Item ( System.Data.DataRow ).

    <xcdg:Column FieldName=”RowStatus” DisplayMemberBinding=”{Bnding Path=.}” Title=”Commands” ReadOnly=”True”>

    Then you can obtain the data item by doing this, as the DataContext of the CellContentTemplate will be the column data:

    <ctl:RowStatusButtonsXceed DataRow=”{Binding Path=.}” />

    Note: We strongly suggest wrapping the DataView in a DataGridCollectionView or DataGridCollectionViewSource and assign it to the ItemsSource instead of the DataView. Several general optimizations were made as well as enhancement to go around particularities of the DataView.

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

    User (Old forums)
    Member
    Post count: 23064

    Thanks, that worked

    Imported from legacy forums. Posted by bbqfrito (had 3422 views)

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