Hello.
I want to toggle value of cell and background of control. when cell is selected. so i trid style of cellvaluepresenter and i can toggle background of cells. but i can not change value of cells
my code is allowed
<Style x:Key="groupdatastyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"/> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Value}" Value="True"/> </MultiDataTrigger.Conditions> <Setter Property="Value" Value="False"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <StackPanel> <TextBlock Background="Gray"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"/> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Value}" Value="False"/> </MultiDataTrigger.Conditions> <Setter Property="Value" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <StackPanel> <TextBlock Background="Blue"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False"/> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Value}" Value="True"/> </MultiDataTrigger.Conditions> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <StackPanel> <TextBlock Background="Blue"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False"/> <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Value}" Value="False"/> </MultiDataTrigger.Conditions> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <StackPanel> <TextBlock Background="Gray"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </MultiDataTrigger> </Style.Triggers> </Style>
...............................
<igDP:UnboundField Label="0" BindingPath="Data.[0]" DataType="{x:Type sys:Boolean}" BindingMode="TwoWay"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource groupdatastyle}"/> </igDP:UnboundField.Settings> </igDP:UnboundField>
You cannot manipulate the Value of a CellValuePresenter using a Style. The Value will be set to a local value based on the value of the underlying dataobject and local values always take precendence over style/trigger setters.
An easy way to change the background of a cell, is to put your content of the cellValuePresenter in a StackPanel, and set the Background of the StackPanel :
<Style x:Key="My.WPF.Styles.AgDataGridFixedTextColumn" TargetType="{x:Type igDP:CellValuePresenter}" > <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <StackPanel Background="#BCD4F6" Margin="0,1,0,0"> <TextBlock Style="{StaticResource My.WPF.Styles.DataGridFixedTextColumnBase}"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter></Style>