Hello,
Welcome to our Microsoft Q&A platform!
When you set the DataGrid.ItemsSource
, it is equivalent to restricting the DataContext
of the DataGrid.Columns
. You cannot bind beyond the scope of the current DataContext
.
Thanks.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a DataGrid that is using a ComboBox in a DataTemplate.
I'm following MVVM pattern for my UWP app. My Xaml page has a view model attached.
The DataGrid is x:Bind'ing to a list of models (AppModels) in the view model.
The ComboBox in the DataGrid needs access to another list of items in the view model (not the AppModel context).
How can I reference the view model on the Xaml page from the DataTemplate? The Xaml docs mention using RelativeSource and AncestorType, but that does not seem to be available in UWP.
BTW - I tried to post a code snippet, but nothing but whitespace was rendered.
Hello,
Welcome to our Microsoft Q&A platform!
When you set the DataGrid.ItemsSource
, it is equivalent to restricting the DataContext
of the DataGrid.Columns
. You cannot bind beyond the scope of the current DataContext
.
Thanks.