Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top