Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1564
Equivalent of DataTemplate ?
posted

Hi,

With the listview I can use the DataTemplate in order to choose which image I want to display.

 The datatemplate test some attributes of my "binding" item and then choose an image to display.

 

How can I do this with xamDataGrid please ? 

Like this :

 

    <DataTemplate x:Key="IsPlayingGraphic">
        <StackPanel>
            <Control x:Name="icon" Template="{StaticResource playingImage}" />
        </StackPanel>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=IsPlaying}" Value="True" >
                <Setter TargetName="icon" Property="Template" Value="{StaticResource playingImage}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsPlaying}" Value="False" >
                <Setter TargetName="icon" Property="Template" Value="{StaticResource notPlayingImage}" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

 

....

 

<GridViewColumn Header="" CellTemplate="{StaticResource IsPlayingGraphic}" Width="20"/>
 

Parents
No Data
Reply
  • 4850
    Offline posted

    The CellValuePresenter is derived from ContentControl which exposes a ContentTemplate property so you can create a style for CellValuePresenter that has a setter for this property.

    There is a CellValuePresenterStyle property off the FieldSettings object that can be set for all field's in the grid by setting xamdataGrid1.FieldSettings.CellValuePresenterStyle = ... or for an individual field via the Field.Settings.CellValuePresenterStyle property.

    I hope this helps.

     

Children
No Data