1

I am having the style trigger like below .

    <Style x:Key="ValidationButtonErrorStyle" TargetType="Button"  BasedOn="{StaticResource ResourceKey=btnStyle}"   >
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="IsEnabled" Value="false" />
            </Trigger>
        </Style.Triggers>
    </Style>

I want to add this style trigger to my button , so that when the validation error happens in the page ,

    <Button Content="{Binding StringResources.XXXX, Source={StaticResource ResourceStrings}}" 
            Style="{StaticResource ResourceKey=ValidationButtonErrorStyle}" 
            Width="150"   
            Command="{Binding XXXX}">
    </Button>

then my button should get disabled. if not it should be in enabled state .

I tried the above code samples but no luck. Can any one point me what i am missing or help me how to achieve this .

4

1 回答 1

1

以下情况如何:

<Style x:Key="ValidationErrorStyle" TargetType="{x:Type Button}">
    <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="True">
            <Setter Property="Button.IsEnabled" Value="False" />
        </Trigger>
    </Style.Triggers>
</Style>
于 2013-09-16T13:26:45.210 回答