微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么不能在Silverlight 4中绑定DataGridTemplateColumn的Visiblity?

似乎不可能在Silverlight 4中绑定DataGridTemplateColumn的visibility属性.我做了一些谷歌搜索,似乎有几个帖子表明它是做 with the fact that it was not a DependencyObject和如何 this would change in SL4,但似乎不是这样.

解决它,我在datagrid加载的事件的代码中做到这一点,但是我很好奇为什么会这样?

这是我得到的错误消息(使用一个返回Visibility值的转换器):

{System.ArgumentException: Object of type 'System.Windows.Data.Binding' cannot be converted to type 'System.Windows.Visibility'.
   at System.RuntimeType.TryChangeType(Object value,Binder binder,CultureInfo culture,Boolean needsspecialCast)
   at System.RuntimeType.CheckValue(Object value,BindingFlags invokeAttr)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters,BindingFlags invokeAttr,Signature sig)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,Object[] parameters,Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj,Object value,Object[] index,Object[] index)
   at MS.Internal.XamlMemberInfo.SetValue(Object target,Object value)
   at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypetoken inType,XamlQualifiedobject& inObj,XamlPropertyToken inProperty,XamlQualifiedobject& inValue)}

解决方法

虽然DataGridTemplateColumn从DependencyObject派生,但它的Visibility属性没有定义DependencyProperty.实际上它没有定义任何依赖属性,因此你仍然无法获得绑定的任何东西.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐