
<Controls:CustomControl WIDth="200" Height="20" TotalCount="{Binding TotalRecordCount}" SuccessCount="{Binding ValIDationCount}" ErrorCount="{Binding ValIDationErrorCount}" margin="0,5,0" HorizontalAlignment="left"> </Controls:CustomControl> 我想让我的自定义usercontrol的私有变量是ErrorCount,SuccessCount和总计数(类型为int32)Bindable所以我可以绑定值给它们.现在,当我尝试将它绑定到我的项目源时,它会给出以下错误e异常消息是“类型为’System.windows.Data.Binding’的对象’无法转换为’system.int32’类型’
非常感谢,
米歇尔
#region public int SuccessCount public int SuccessCount { get { return (int)GetValue(SuccessCountProperty); } set { SetValue(SuccessCountProperty,value); } } public static Readonly DependencyProperty SuccessCountProperty = DependencyProperty.Register( "SuccessCount",typeof(int),typeof(CustomControl),new PropertyMetadata(0,OnSuccessCountPropertyChanged)); private static voID OnSuccessCountPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) { CustomControl source = d as CustomControl; int value = (int)e.NewValue; // Do stuff when new value is assigned. } #endregion public int SuccessCount 总结 以上是内存溢出为你收集整理的silverlight – 使我的Usercontrol的属性可绑定全部内容,希望文章能够帮你解决silverlight – 使我的Usercontrol的属性可绑定所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)