能见度自动绑定与命名规则 [英] Visibility Autobinding with naming convention

查看:188
本文介绍了能见度自动绑定与命名规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢卡利和命名约定具有约束力,感到惊讶的是
 可视性是不以同样的方式的CanNAME公约用来防止一个操作约束。
 据我所知道的是,只有当在绑定卡利明确地使用,而不是像自动防护方法所使用的BooleanToVisibilityConverter。所以我想修改自动绑定到源布尔?ControlNameIsVisible()(空塌陷等于)或类似。我在想,如果这是正确的做法,如果洙如果有人已经做好了实施和可以在这里分享。

I really like Caliburn and the naming convention binding and was surprised that the Visibility is not bound in the same way the "CanNAME" Convention is used to guard an Action. As far as I know is the BooleanToVisibilityConverter only used when Binding is explicitly used in Caliburn and not automatically like the guard method. So I was thinking to modify the source to bind automatically to "bool? ControlNameIsVisible()" (null equals collapse) or similar. I was wondering if that is the right approach and if soo if somebody has done the implementation already and could share it here.

推荐答案

您可以,如果你想使用这种方法,这是完全合理的。另一种方法是使用一个边境相同的名称作为您的视图模型中的布尔属性。 Caliburn.Micro将设置边框的基础上,布尔属性的值的可见性。

You could use this approach if you wanted, it's perfectly reasonable. Another approach is to use a Border with the same name as a boolean property on your view model. Caliburn.Micro will set the visibility of the Border based on the value of the boolean property.

<Border x:Name="ControlIsVisible">
  <TextBox x:Name="MyControl" ... />
</Border>

这篇关于能见度自动绑定与命名规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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