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

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

问题描述

按照我的之前的帖子我现在正在尝试绑定可见性DataGridColumns 到 VM 通知属性.MSDN建议我应该能够轻松做到这一点.

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.

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

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}"/>

此复选框控制可见性的反应正如我所料.当我在 DataTextColumn 上设置相同的绑定时,我在 XAML 的 Visibility= 行上收到一个 AG_E_BAD_PARSER 错误:

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

推荐答案

DataGridTextColumn 上的可见性与复选框不同.基本上,它不是依赖属性,不能绑定数据.如果你需要这个功能,你可以继承 DataGridTextColumn 并添加你自己的依赖属性来获取行为.

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.

  • 矩形从 UIElement 获取其 Visibility 属性,并且是一个依赖属性
  • DataGridTextColumn 从 DataGridColumn 获取 Visibility 并且不是依赖属性.

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

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