Binding ItemsSource programmatically
问题 What is the equivalent of this in c# code? <ListView x:Name="taskItemListView" DataContext="{Binding SelectedItem, ElementName=itemListView}" ItemsSource="{Binding taskItems}"> ... </ListView> I've tried the following code, but it doesn't seem to work... Binding b = new Binding(); b.Path = new PropertyPath("taskItems"); DependencyProperty dp = DependencyProperty.Register("itemsSource", typeof(object), typeof(object), null); BindingOperations.SetBinding(taskItemListView, dp, b); Edit : Based