WPF中的ItemsSource以编程方式明确地进入C#

时间:2009-04-23 14:12:43

标签: c# xaml

快速提问,如何将其转换为后端代码?即c#

ItemsSource =“{Binding Source = {StaticResource List1},XPath = Entry}”

1 个答案:

答案 0 :(得分:5)

Binding items = new Binding();
items.Source = FindResource("List1");
items.XPath = "Entry";
myItemsControl.SetBinding(ItemsControl.ItemsSourceProperty, items);

myItemsControl是设置ItemsSource的控件。