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=" ">
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 

.
精彩评论