0

フィールドの値に指定されたテキストが含まれている場合、テキスト ボックスの背景を変更しようとしています。私が遭遇する問題は、既にフィールドに適用されているスタイルがあり、次の例のようにスタイルのプロパティを上書きしようとしましたが、成功しなかったことです。どうすればこれを達成できますか?

<TextBox Grid.Column="1"
        HorizontalAlignment="Right"
        Text="{Binding CustomerType}" >

    <TextBox.Style BasedOn="{DynamicResource SelectableTextStyle}">
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding CustomerType}" Value="Unknown">
                    <Setter Property="TextBox.Background" Value="Tomato"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBox.Style>
</TextBox>
4

1 に答える 1