空字符串签入触发器 [英] Empty String Check in Trigger

查看:24
本文介绍了空字符串签入触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查触发器中的空字符串

How can I check the empty string in triggers

<Trigger Property="Source" SourceName="ControlName"  Value="">
     <Setter Property="Height" Value="0" TargetName="ControlName" />
</Trigger>

如果 imageControl 的源是空字符串或未设置,我是否已将控件的高度设置为 0?我该怎么做,基本上如果没有设置图像,那么我想隐藏模板中的图像控件.

I have set the Height of the Control to 0 if the source of the imageControl is empty string or not set? How can I do it, Basically If the image is not set then I want to hide the image control in the template.

提前致谢.

推荐答案

Kent 认为 Source 不是字符串是正确的,但如果您确实有要检查的 sting 属性,则可以使用静态 String.Empty 值:

Kent is correct that the Source is not a string but if you do have a sting property to check against you can use the static String.Empty value:

Value="{x:Static sys:String.Empty}"

和 sys 命名空间声明为

and the sys namespace declared as

xmlns:sys="clr-namespace:System;assembly=mscorlib"

这篇关于空字符串签入触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆