开发者

How do I match "newline" in a DataTrigger?

In my XAML, I am trying to implement the folowing:

<DataTrigger Binding="{Binding Path=Word开发者_运维百科}" Value="\n">

but this does not work, even though Word is \n. I suspect that \n is not the right way to express newline in XAML, but what would be?


Does this solve the problem?

<DataTrigger Binding="{Binding Path=Word}" Value="&#10;">


The following works, you can try it:

xmlns:sys="clr-namespace:System;assembly=mscorlib"
<TextBox AcceptsReturn="True">
    <TextBox.Style>
        <Style TargetType="TextBox">
            <Style.Triggers>
                <Trigger Property="Text" Value="{x:Static sys:Environment.NewLine}">
                    <Setter Property="Background" Value="Green"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </TextBox.Style>
</TextBox>


After some testing, I found the answer is &#010;.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜