Given a usercontrol bound to a viewmodel defined as follows
class MyViewModel
{
public DataView MyView { get; set; }
public DataView MyTypes { get; set; }
}
and the XAML is roughly marked as follows
<Grid>
<dxg:GridControl AutoPopulateColumns="True" Name="gridControl1" ItemsSource="{ Binding MyView}">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="col1">
<dxg:GridColumn.EditTemplate>
<ControlTemplate>
<dxe:ComboBoxEdit Name="cmbTypes"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}},
Path=ViewModel.MyTypes}"/>
</ControlTemplate>
</dxg:GridColumn.EditTemplate>
</dxg:GridColumn>
<dxg:GridColumn FieldName="col2"/>
<dxg:GridColumn FieldName="col3" Width="75"/>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView Name="tableView1" AutoWidth="True" ShowTotalSummary="True" />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
bound as follows
internal MyViewModel ViewModel
{
get { return (MyViewModel)DataContext; }
set { DataContext = value; }
}
Of course the ComboBox does not show the selections from ListTypes which does have values
Question is – how to reference the ListTypes property of the ViewModel
from Grid.Column where the Grid is Bound to a DataView MyItems which does not have the property ListTypes, which is at the same level as ListTypes !!!
Any help is appreciated
If I’ve understood the question correctly, I’d expect the following to work:
It may be that
Path=ViewModel.MyTypesis not working simply because you haven’t implemented change notification on theViewModelproperty. As I say, though – you should be able to get along fine withPath=DataContext.MyTypes.Note: you seem to refer to the property as both
MyTypesandListTypesin the question – not sure which is correct for your object model.