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
695
Style not applied properly
posted

I've have style defined as a resource to format a particular row. All the properties work fine but the background is being ignored. If i comment out the <Setter Property="template"... then the background setter is applied. Any ideas why there is this conflict?

<Style x:Key="cvpDirectionStyle" TargetType="{x:Type igDP:CellValuePresenter}">

<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Value, Converter={StaticResource cvpForegroundBrushConverter}}"/>

<Setter Property="Background" Value="#D6CE78"/>

<Setter Property="FontFamily" Value="Wingdings 3"/>

<Setter Property="FontSize" Value="22"/>

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

<ContentControl Content="{Binding RelativeSource={RelativeSource TemplatedParent},

Path=Value,

Converter={StaticResource cvpDirectionChangeConverter}}"/>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

Parents
No Data
Reply
  • 17559
    posted

     

    Hello martinfenech,

     

    I reviewed your issue and what seems to cause this behavior in your snippet, is that when you set the template property, you lose the original template which uses the background property of the CellValuePresenter Class. If you want to use the background setter you can change your template to:

     

    <Style x:Key="cvpDirectionStyle" TargetType="{x:Type igDP:CellValuePresenter}">

    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSourceSelf}, Path=Value, Converter={StaticResource cvpForegroundBrushConverter}}"/>

    <Setter Property="Background" Value="#D6CE78"/>

    <Setter Property="FontFamily" Value="Wingdings 3"/>

    <Setter Property="FontSize" Value="22"/>

    <Setter Property="Template">

                    <Setter.Value>

                        <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

                            <Grid Background="{TemplateBinding Background}" >

                                <ContentControl  Content="{Binding RelativeSource={RelativeSource TemplatedParent},

    Path=Value}"/>

                            </Grid>

                        </ControlTemplate>

                    </Setter.Value>

                </Setter>

    </Style>

     

     Please let me know if you need further assistance.

     

     

     

Children
No Data