Ritesh
Ritesh

Reputation: 362

MultiDataTrigger does not change IsReadOnly property of TextBox

I am using MultiDataTrigger in multi-line TextBox:

<TextBox TextWrapping="Wrap" ScrollViewer.CanContentScroll="True"
                    FlowDirection="RightToLeft" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"
                    Text="{Binding ArabicDescription}" IsReadOnly="True">
    <TextBox.Style>
        <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Path=EnableNewEntry}" Value="True" />
                        <Condition Binding="{Binding Path=AllowArabic}" Value="True" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsReadOnly" Value="False" />
                    <Setter Property="Background" Value="Blue" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </TextBox.Style>
</TextBox>

When EnableNewEntry and AllowArabic become true, the TextBox is supposed to become Read-only. For just testing, I changed background color as well. Problem is IsReadOnly does not change where as Background duly changes.

I also tried following setter, but it does not work either:

<Setter Property="TextBox.IsReadOnly" Value="False" />

What am I doing wrong?

Ritesh

Upvotes: 0

Views: 737

Answers (1)

iltzortz
iltzortz

Reputation: 2412

You should not expicitly set IsReadolny to True Use the MultiDataTrigger you already have to set it to false and another one to set it to true whenever you want it but DO NOT SET IT at TextBox properties

Upvotes: 1

Related Questions