Quantcast
Viewing all articles
Browse latest Browse all 18858

Binding problem when different ViewModels are used

Dear Reader,

I am facing problem when binding a static data for a ComboBox ItemSource and then binding a SelectedItem to the actual viewModel. The code looks as follows

<ComboBox 
ItemsSource="{Binding Source={x:Static local:StaticData.Instance}, Path=StaticModel,Mode=OneWay}" 
SelectedItem="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, Path=DataContext.SelectedKey, Mode=TwoWay}" 
Margin="0" Name="Test1" 
VerticalAlignment="Top" 
Width="189" Height="23" 
HorizontalAlignment="Left"/>

This Combobox is placed in CellEditTemplate of a DataGrid.

In above XAML StaticData.Instance is a Singleton Instance and SelectedKey is a property of Actual DataModel of DataGrid's ItemSource.

The setter of SelectedKey is never reached with above code.

Can anyone tell me what am I doing wrong?

Thanks,

Rajiv



- Rajiv


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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