I tried to used the style as mentioned in this post http://ko.infragistics.com/community/forums/p/51185/268258.aspx
However instead of using the EditorStyle (Editor) I defined the CellValuePresenterStyle. The reason for this was I already have CellValuePresenterStyle for Border related properties. Do I need to define both the EditorStyle and CellValuePresenterStyle.
In the following example 'name' is using EditorStyle and works. While 'department' is using CellValuePresenterStyle' and does NOT work.
<igDP:XamDataGrid BindToSampleData="True"> <igDP:XamDataGrid.Resources> <Style x:Key="StrikeThroughEditor" TargetType="{x:Type editors:XamTextEditor}" BasedOn="{StaticResource {x:Type editors:XamTextEditor}}"> <Style.Resources> <Style TargetType="{x:Type controls:SimpleTextBlock}"> <Setter Property="TextDecorations" Value="Strikethrough" /> </Style> </Style.Resources> </Style> <Style x:Key="StrikeThroughCellValuePresenter" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"> <Style.Resources> <Style TargetType="{x:Type controls:SimpleTextBlock}"> <Setter Property="TextDecorations" Value="Strikethrough"/> </Style> </Style.Resources> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="name"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource StrikeThroughEditor}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="department"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource StrikeThroughCellValuePresenter}" /> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
<igDP:XamDataGrid BindToSampleData="True"> <igDP:XamDataGrid.Resources> <Style x:Key="StrikeThroughEditor" TargetType="{x:Type editors:XamTextEditor}" BasedOn="{StaticResource {x:Type editors:XamTextEditor}}"> <Style.Resources> <Style TargetType="{x:Type controls:SimpleTextBlock}"> <Setter Property="TextDecorations" Value="Strikethrough" /> </Style> </Style.Resources> </Style>
<Style x:Key="StrikeThroughCellValuePresenter" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"> <Style.Resources> <Style TargetType="{x:Type controls:SimpleTextBlock}"> <Setter Property="TextDecorations" Value="Strikethrough"/> </Style> </Style.Resources> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="name"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource StrikeThroughEditor}" /> </igDP:Field.Settings> </igDP:Field>
<igDP:Field Name="department"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource StrikeThroughCellValuePresenter}" /> </igDP:Field.Settings> </igDP:Field>
</igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Hi Bhavesh,
The only thing I can think of is that the style located in the CellValuePresenter's Style.Resources for the SimpleTextBlock can't cross the ContentPresenter barrier. The CellValuePresenter template has a ContentPresenter called PART_EditorSite. Depending on the data type of the column the content placed in the ContentPresenter will differ. This is acting like a barrier and content inside the presenter doesn't know anything about the CellValuePresenter which means it ignores the style for SimpleTextBlock.
This explains why it doesn't work when using the CellValuePresenter. You need to use the EditorStyle property in order to apply the Strikethrough to the text as this style is directly applied to the ValueEditor located in the CellValuePresenter's PART_EditorSite.
Hi Rob,
I updated the FieldSettings and setup both CellValuePresenterStyle and EditorStyle. And this fixes the problem.
I have a follow-up question, I remember reading somewhere is documentation about setting either EditorStyle or CellValuePresenterStyle. Here I am setting both. Is this going to give me grief ?
<igDP:XamDataGrid BindToSampleData="True"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type controls:SimpleTextBlock}" BasedOn="{StaticResource {x:Type controls:SimpleTextBlock}}"> <Setter Property="TextDecorations" Value="Strikethrough" /> </Style> <Style x:Key="StrikeThroughEditor" TargetType="{x:Type editors:XamTextEditor}" BasedOn="{StaticResource {x:Type editors:XamTextEditor}}"> <Style.Resources> <Style TargetType="{x:Type controls:SimpleTextBlock}"> <Setter Property="TextDecorations" Value="Strikethrough" /> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"></Style> </Style.Resources> </Style> <Style x:Key="StrikeThroughCellValuePresenter" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"> <Setter Property="BorderBrush" Value="Brown"></Setter> <Setter Property="BorderThickness" Value="2"></Setter> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="name"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource StrikeThroughEditor}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="department"> <igDP:Field.Settings> <!--NOTE: Setting both the CellValuePresenterStyle and EditorStyle --> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource StrikeThroughCellValuePresenter}" EditorStyle="{StaticResource StrikeThroughEditor}"/> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
<igDP:XamDataGrid BindToSampleData="True"> <igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type controls:SimpleTextBlock}" BasedOn="{StaticResource {x:Type controls:SimpleTextBlock}}"> <Setter Property="TextDecorations" Value="Strikethrough" /> </Style> <Style x:Key="StrikeThroughEditor" TargetType="{x:Type editors:XamTextEditor}" BasedOn="{StaticResource {x:Type editors:XamTextEditor}}"> <Style.Resources> <Style TargetType="{x:Type controls:SimpleTextBlock}"> <Setter Property="TextDecorations" Value="Strikethrough" /> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"></Style> </Style.Resources> </Style>
<Style x:Key="StrikeThroughCellValuePresenter" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"> <Setter Property="BorderBrush" Value="Brown"></Setter> <Setter Property="BorderThickness" Value="2"></Setter> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="name"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource StrikeThroughEditor}" /> </igDP:Field.Settings> </igDP:Field>
<igDP:Field Name="department"> <igDP:Field.Settings> <!--NOTE: Setting both the CellValuePresenterStyle and EditorStyle --> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource StrikeThroughCellValuePresenter}" EditorStyle="{StaticResource StrikeThroughEditor}"/> </igDP:Field.Settings> </igDP:Field>