skjagini
skjagini

Reputation: 3217

How to apply WPF styles based on top of another style without using BasedOn property

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

Upvotes: 0

Views: 1694

Answers (1)

Jurica Smircic
Jurica Smircic

Reputation: 6445

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.

Upvotes: 2

Related Questions