Silverlight DataGridTextColumn绑定可见性 [英] Silverlight DataGridTextColumn Binding Visibility

查看:226
本文介绍了Silverlight DataGridTextColumn绑定可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的之前的帖子之后,我现在正在尝试绑定可见性的DataGridColumns到VM通知属性。 MSDN 建议我可以轻松地做到这一点。



我已经有一个值转换器和VM通知属性,我知道的作品(我有在我的页面上的另一个元素上测试了这些:

 < CheckBox x:Name =chkAllTeamsVisibility ={Binding Converter = {StaticResource BoolToVisibilityConverter},Path = AllTeams}/> 

此复选框控件的可见性反映为当我在DataTextColumn上设置相同的绑定时,我在XAML的 Visibility = 行上得到一个AG_E_BAD_PARSER错误:

 code>< data:DataGridTextColumn 
Visibility ={Binding Converter = {StaticResource BoolToVisibilityConverter},Path = AllTeams}
/>
/ pre>

任何想法任何人?
感谢
标记

解决方案

在DataGridTextColumn上的可见性是复选框中的不同的野兽。基本上,它不是依赖属性,不能是数据绑定的。如果您需要此功能,您可以继承DataGridTextColumn并添加您自己的依赖属性来获取行为。




  • 矩形从UIElement获取其Visibility属性并且是依赖属性

  • DataGridTextColumn从DataGridColumn获取其可见性,不是依赖属性。


Following my earlier post I am now trying now to bind the visibility of DataGridColumns to a VM notification property. MSDN suggests I should be able to do this with ease.

I already have a value convertor and VM notification property that I know works (I have tested these on another element on my page:

<CheckBox x:Name="chkAllTeams" Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=AllTeams}"/>

This checkbox control visibility reacts as I would expect. When I set the same binding on the DataTextColumn I get an AG_E_BAD_PARSER error on the Visibility= line of XAML:

<data:DataGridTextColumn 
Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=AllTeams}"
/>

Any ideas anyone? Thanks, Mark

解决方案

Visibility on the DataGridTextColumn is a different beast on the checkbox. Basically, it isn't a dependency property and can't be data-bound. If you need this functionality, you can subclass DataGridTextColumn and add your own dependency property to get the behavior.

  • Rectangle gets its Visibility property from UIElement and is a dependency property
  • DataGridTextColumn gets its Visibility from DataGridColumn and isn't a dependency property.

这篇关于Silverlight DataGridTextColumn绑定可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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