Home Forums WPF controls Xceed DataGrid for WPF V1.1 – CellContentTemplateSelector

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

    I’m getting the following error with V1.1:-

    ‘XamlParseException: Cannot add content of type ‘Xceed.Wpf.DataGrid.Column’ to an object of type ‘Xceed.Wpf.DataGrid.ColumnCollection’. Error at object ‘Xceed.Wpf.DataGrid.Column’ in markup file’

    My XAML is:-

    <xcdg:Column ReadOnly=”True” Title=”Score and Comment” Width=”500″
    CellContentTemplateSelector=”{StaticResource scoreCellTemplateSelector}” />

    It was fine in V1.0. Any suggestions?

    Michael

    Imported from legacy forums. Posted by Michael (had 4397 views)

    Xceed Support
    Member
    Post count: 5658

    Starting from version 1.1, it is now mandatory to give a FieldName to a column.

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

    User (Old forums)
    Member
    Post count: 23064

    I should read the notes more thoroughly shouldn’t I! 🙂

    I remember seeing that now. Thanks
    Michael

    Imported from legacy forums. Posted by Michael (had 326 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m still having problems with this I’m afraid.

    Setting the FieldName means the item passed to DataTemplateSelector.SelectTemplate is now the value from the bound field instead of the parent row as in V1.0.

    For example, I have a DataGridControl displaying items subclassed from a common base class. I wish to select a template based on the type of the subclassed item (row) in the control. I think for most of the DataTemplateSelector examples I’ve seen, the SelectTemplate method passes the row item as the Item parameter. This is how V1.0 behaved but setting the FieldName=”SomeProperty” means it is now passing a property value instead of the parent class instance. Hope that makes sense.

    I can redesign the base class to return a reference to itself but I think the original behaviour was the correct one.

    Michael

    Imported from legacy forums. Posted by Michael (had 492 views)

    Xceed Support
    Member
    Post count: 5658

    What you could do is to also specify a display member binding that binds to the parent row data object…

    <code>
    <xcdg:Column FieldName=”SomeProperty”
    ReadOnly=”True”
    Title=”Score and Comment”
    Width=”500″
    CellContentTemplateSelector=”{StaticResource scoreCellTemplateSelector}”
    DisplayMemberBinding=”{Binding .}” />

    </code>

    Specifying the display member binding will ensure that one is not created automatically for the Column.

    Let me know if that does the trick.

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

    User (Old forums)
    Member
    Post count: 23064

    Yep, that worked.

    Michael

    Imported from legacy forums. Posted by Michael (had 5282 views)

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