大佬教程收集整理的这篇文章主要介绍了wpf – 绑定绑定的Path属性,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
视图模型:
public @R_944_10495@ng CurrentValue { get { var property = this.GetType().GetProperty(CurrentPath); return property.GetValue(this,null); } }
使用转换器:
public class CurrentPathToValueConverter : IValueConverter { public object Convert(object value,Type targetType,object parameter,CultureInfo culturE) { var viewmodel = (viewmodel)value; var property = viewmodel.GetType().GetProperty(viewmodel.CurrentPath); var currentValue = property.GetValue(viewmodel,null); return currentValue; } public object ConvertBACk(object value,CultureInfo culturE) { throw new NotImplementedException(); } }
当然,如果你想获得对象的简单属性,这些只能工作 – 如果你想得到更复杂的东西,你的反射代码会变得更加复杂.
除非您正在构建类似属性网格的东西,或者出于某种其他原因,您实际上想要反思应用程序中运行的对象,我建议您重新审视您的设计,因为反射实际上仅适用于少数情况.
以上是大佬教程为你收集整理的wpf – 绑定绑定的Path属性全部内容,希望文章能够帮你解决wpf – 绑定绑定的Path属性所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。