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
1285
Style not being applied
posted

I have a usercontrol and has a style to style all XamTextEditors in resources as such:

 <UserControl.Resources>
        <ObjectDataProvider x:Key="dpContract"  />
        <Style TargetType="{x:Type igEditors:XamTextEditor}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip"
                        Value="{Binding RelativeSource={RelativeSource Self},
                       Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

The editor code:

<igEditors:XamTextEditor Grid.Row="0" Grid.Column="0" Theme="[current]"  Name="xamTextEditorContractNo"
                                             HorizontalAlignment="Stretch" TextChanged="xamTextEditorContractNo_TextChanged"
                                             Text="{Binding Path=ContractNo, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True}" />

 

The tooltip is not showing up on validation error.  If I give a key to style and set the style property in XamTextBox it works.  Any ideas?

Using 9.2

Thanks

Parents
  • 54937
    Verified Answer
    Offline posted

    In WPF there is only 1 local style. If the Style property is set that is used as the local style. Otherwise WPF uses the first style it finds as it traverses the element and its ancestor's resources. When you set the Theme property of the control you are putting Styles into the control's Resources so that style ends up being the local style that WPF finds/uses which is why the one you have higher up the ancestor chain (i.e. in the UserControl's resources) is not being used. You need to either remove the Theme property setter or put the Style into the xamTextEditor's Resources which of course would prevent the Theme's Style from being used.

Reply Children