Home Forums WPF controls Xceed DataGrid for WPF Access to the row object from the CellContentTemplate

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

    For one of my columns I am using an Edit Template and a CellContentTemplate (in which I use a DataTrigger). The DataTrigger needs to check a value in the row object (the IsSelfReferent value), but it only has access to the column value (set with FieldName=”OtherThing”). If I change the column value to refer to the row object rather than the column value, the CellEditorBinding (SelectedItem=”{xcdg:CellEditorBinding}”) in the Edit Template doesn’t work. See code below:

    <b>The column definiton:</b>
    <xcdg:Column FieldName=”OtherThing” Title=”Thing” CellContentTemplate=”{StaticResource ThingColumnCellTemplate}” CellEditorDisplayConditions=”MouseOverCell” >
    <xcdg:Column.CellEditor>
    <xcdg:CellEditor EditTemplate=”{StaticResource EditThingColumnCellTemplate}”/>
    </xcdg:Column.CellEditor>
    </xcdg:Column>

    <b>The ThingColumnCellTemplate:</b>
    <DataTemplate x:Key=”ThingColumnCellTemplate”>
    <StackPanel Orientation=”Horizontal” >
    <TextBlock Name=”thingTextBlock” Text=”{Binding Path=OtherThing.Name}”/>
    <Image x:Name=”thingReferenceImage” Source=”Images\undo.gif” Stretch=”None” Visibility=”Visible” HorizontalAlignment=”Right”/>
    </StackPanel>
    <DataTemplate.Triggers>
    <DataTrigger Binding=”{Binding Path=IsSelfReferent}” Value=”true”>
    <Setter TargetName=”thingReferenceImage” Property=”Image.Visibility” Value=”Hidden”/>
    </DataTrigger>
    </DataTemplate.Triggers>
    </DataTemplate>

    <b>The edit template definition:</b>
    <DataTemplate x:Key=”EditThingColumnCellTemplate”>
    <StackPanel Orientation=”Horizontal” >
    <ComboBox Name=”thingComboBox” ItemsSource=”{Binding Source={StaticResource highLevelThings}}” SelectedItem=”{xcdg:CellEditorBinding}” />
    <Image x:Name=”editThingReferenceImage” Source=”Images\undo.gif” Stretch=”None” Visibility=”Hidden” HorizontalAlignment=”Right”/>
    </StackPanel>
    <DataTemplate.Triggers>
    <DataTrigger Binding=”{Binding Path=IsSelfReferent}” Value=”false”>
    <Setter TargetName=”editThingReferenceImage” Property=”Image.Visibility” Value=”Visible”/>
    </DataTrigger>
    </DataTemplate.Triggers>
    </DataTemplate>

    Is there some way I can access the row object from inside the columntemplate, without binding to it in the column definition?

    Someone, please!

    Imported from legacy forums. Posted by Tove (had 580 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve found the solution, so consider the “issue” solved.

    Imported from legacy forums. Posted by Tove (had 2626 views)

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