简体   繁体   中英

Textbox style trigger with “IsReadOnly” not working

I've made an application resource with a style which should be triggered if the textbox has the "IsReadOnly" property. Looks like this:

<Application.Resources>

    <Style TargetType="{x:Type TextBox}" >
        <Style.Triggers>
            <Trigger Property="IsReadOnly" Value="True">
                <Trigger.Setters>
                    <Setter Property="Background" Value="Black" />
                </Trigger.Setters>
            </Trigger>
        </Style.Triggers>
    </Style>

</Application.Resources>

However, the program doesn't react to this. It works when I use IsEnabled=True. However IsEnabled=False doesn't work either. So, question: Do the triggers only work if you check for "True"? And is IsReadOnly not supported at all? If so: How do I know which control properties are actually supported?

See an answer for this problem by following the provided link:

DataTrigger problem with textbox

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM