0

I am styling CellValuePresenter (From Infragistics) to give different look to Gid Lines and have defined a style (gridLineStyle) and applied to the Grid's CellValuePresenterStyle Property.

I have discovered that there are columns for which custom templates are defined by templating CellValuePrenter and the grid lines are not visible (as expected). I can make it work by applying BasedOn property as in

 <Style x:Key="gridLineStyle" TargetType="ig:CellValuePresenter">
      <Setter Property="BorderThickness" Value="0,0,1,1"/>
      <Setter Property="BorderBrush" Value="{Binding Path=BorderBrushForAllCells,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type pwc:CarbonBlotter}}}"/> 
    </Style>

 <Style x:Key="anotherColumnStyle" TargetType="{x:Type ig:CellValuePresenter}"   BasedOn="{StaticResource gridLineStyle}">
      <Setter Property="Template">
      ....

<pwc:BaseXamDataGrid>
    <pwc:BaseXamDataGrid.FieldSettings>
            <ig:FieldSettings CellValuePresenterStyle="{StaticResource gridLineStyle}"
             ...

But there are many styles with custom templates, and just wondering whether I can define a style without using BasedOn property and yet inheriting default style

skjagini
  • 3,142
  • 5
  • 34
  • 63
  • 1
    Chances are that you can't skip the BasedOn without recreating the entire style definition and it's probably a lot of work to do that. What you could do is you could skip the x:Key attribute and this style will become default for all `ig:CellValuePresenter`s in its scope – Sten Petrov Apr 22 '13 at 19:47
  • @StenPetrov If I remove the x:key from gridLinesStyles it would become default for all the CellValuePresenters except the ones templated (as in anotherColumnStyle), which will not have default style inherited, isn't it. Which is exactly what I am trying to solve. – skjagini Apr 22 '13 at 19:56
  • correct. If you've used the Style property somewhere then the default style won't be this one. – Sten Petrov Apr 22 '13 at 19:58
  • Doesn't Infragistics provide xaml resource files with styles? If it does you can modify the xaml file to meet your needs... – Dean Kuga Apr 22 '13 at 20:08
  • @DeanKuga When you restyle it as in anotherColumnStyle it will not respect original style any more, isn't it? – skjagini Apr 22 '13 at 20:13

1 Answers1

2

You can find the complete CellValuePresenter style definition in your infragistics installation folder under DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml You can copy that style into your App.xaml under Application.Resources, modify it as you wish and that should become your new default style for CellValuePresenter.

Jurica Smircic
  • 6,117
  • 2
  • 22
  • 27
  • When you restyle it as in anotherColumnStyle it will not respect original style any more, isn't it? – skjagini Apr 22 '13 at 20:12
  • If you put the style definition in the Application.Resources, that style will become the new "original style". That't the reason Infragistics has provided DefaultStyles folder with the installation. So you can restyle everything according to your needs. If you don't need to change the style on the global application level, you can put in the Resources of the UserControl or even inside resources of the XamDataGrid. – Jurica Smircic Apr 22 '13 at 20:58