Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Multiple DataContexts

$
0
0

I have a MainWindow with a DataContext

On this MainWindow I have a UserControl which has a bunch of Text boxes which are bound to data from the MainWindow's DataContext and this works correctly.

I also have a list box which I want to bind to a collection which was created in the same UserControl, I don't want to get data from external source, because the data is only for this class only, it builds the fields to be displayed. And I can't get this list box to bind to the collection.

My question is how to I bind this ListBox to the Collection and still have the other TextBoxes binding the the DataContext from the MainWindow.

I know I can add code to the underlying code, but I want to set using XAML.

Data.ItemsSource = MyCollection;

Thank You


Peter


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>