使用 multiDataTrigger 时出现 TextBlock 异常
我正在尝试向文本块的可见性属性添加 2 个触发器。 以下代码会导致“TextBlock 异常”。知道为什么吗?
<TextBlock Name="tb2"
Style="{StaticResource MyPageTextStyle}"
Text="{x:Static res:MyResources.MyText}"
Visibility="Collapsed"
>
<TextBlock.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{BindingPath=Class1.IsBlue}" Value="true" />
<Condition Binding="{Binding Path=Class1.IsGreen}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="tb2" Property="TextBlock.Visibility" Value="Visible" />
</MultiDataTrigger>
</TextBlock.Triggers>
</TextBlock>
I'm trying to add 2 triggers to the visibility property of a textblock.
The following code causes a "TextBlock exception". Any idea why?
<TextBlock Name="tb2"
Style="{StaticResource MyPageTextStyle}"
Text="{x:Static res:MyResources.MyText}"
Visibility="Collapsed"
>
<TextBlock.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{BindingPath=Class1.IsBlue}" Value="true" />
<Condition Binding="{Binding Path=Class1.IsGreen}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter TargetName="tb2" Property="TextBlock.Visibility" Value="Visible" />
</MultiDataTrigger>
</TextBlock.Triggers>
</TextBlock>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是向文本块添加触发器,而是向文本块样式添加触发器...直接向控件添加触发器将引发 xaml 异常...
尝试做这样的事情...
Instead of adding triggers to textblock add triggers to textblock style... some how adding triggers directly to control will throw xaml exceptions...
try to do some thing like this...