【发布时间】:2018-05-28 18:11:46
【问题描述】:
有没有办法在不使用deprecatedFrameworkElementFactory 或XamlReader.Load 的字符串解释方法对(related question) 或(another related) 编码的情况下构建DataTemplate?
DataTemplate dt = new DataTemplate();
StackPanel sp = new StackPanel();
ComboBox cellComboBox = new ComboBox() { Visibility = Visibility.Collapsed };
CheckBox cellCheckBox = new CheckBox() { Visibility = Visibility.Collapsed };
sp.Children.Add(cellComboBox);
sp.Children.Add(cellCheckBox);
// then add the stackpanel somehow?
更新:为什么?
这是一个可能需要多年支持的新程序。 XamlReader 在运行时解析具有构造函数、方法、属性的东西的字符串......感觉很笨拙。 FrameworkElementFactory 已在多个版本中被弃用,但从未有过真正的替代品。
【问题讨论】:
标签: c# wpf datatemplate