Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ItemsSource in WPF Declaritively into C# Programmatically

Tags:

c#

xaml

Quick question, how do I convert this into back end code? i.e. c#

ItemsSource="{Binding Source={StaticResource List1}, XPath=Entry}"


1 Answers

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

Where myItemsControl is the control on which to set ItemsSource.

like image 117
Josh G Avatar answered Apr 13 '26 05:04

Josh G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!