Home Forums WPF controls Xceed DataGrid for WPF CardView IsMainColumn problem

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

    I have a series of data objects in an ObservableCollection that I am assigning to the ItemsSource on a DataGridControl. I have set AutoCreateColumns to false, and manually defined the column information in the DataGridControl.Columns collection. One of the columns is the ObjectID property on my data objects. The property is a Guid used to keep track of the record in the database. I defined a column (first column), set the IsMainColumn to true, but visible to false. The ObjectID keeps appearing as the header of the CardView. In TableView, the column is not visible (which is correct). Is there any way around this, or should I not define the ObjectID column.

    Thanks,
    Joe

    Imported from legacy forums. Posted by Joe (had 4268 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Joe,

    The IsMainColumn property of the Column class is used by the CardView by default as the card title unless you specify a CardTitleTemplate in your CardView… In that case, the template will be used and the ObjectID will remain hidden….

    Here is a quick sample on how you can achieve that ( I abstract most of properties, only focusing on what is necessary for this):

    <hr>
    <code>
    <DataGridControl>
    <DataGridControl.View>
    <CardView>
    <CardView.CardTitleTemplate>
    <DataTemplate>
    <TextBlock Text=”My Custom Card Title” />
    </DataTemplate>
    </CardView.CardTitleTemplate>
    </CardView>
    </DataGridControl.View>
    </DataGridControl>
    </code>
    <hr>

    Note that you could also load your template using a “{StaticResource xxx}” statement.

    Let us know if you encounter problems while implementing this.

    Good Day.

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

    User (Old forums)
    Member
    Post count: 23064

    Hi Marcus,
    Thanks for the info. Any way to bind that property to a field? I am guessing I would replace the <TextBlock> with a <DataCell>.

    Thanks,
    Joe

    Imported from legacy forums. Posted by Joe (had 370 views)

    Xceed Support
    Member
    Post count: 5658

    Actually, the purpose of the IsMainColumn property is not to identify the primary key of your dataset but to flag that Column as the one containing the “main” information of the record…

    I suggest setting the IsMainColumn to true for the column you want to display in the card’s title.

    As for setting a DataCell in the DataTemplate for the CardTitleTemplate, this scenario is not covered at the moment. We only support adding explicitly a DataCell in the ControlTemplate of the DataRow (see CustomViews Sample Application ).

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

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the help, the header is working as expected now.

    Joe

    Imported from legacy forums. Posted by Joe (had 5573 views)

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