c# - How to access ObservableCollection nested in view model -
i have simple single window wpf app using mvvm. xaml binded mainviewmodel.cs class, contains observablecollection sites. sitemodel class has property named owners, contains second observablecollection companies.
i need bind companies property combobox in xaml. combobox nested in datagrid. situation described below.
<datagrid name="uxsitegrid" dockpanel.dock="top" itemssource="{binding sites, source={staticresource viewmodel}}" autogeneratecolumns="false" margin="5,5,5,0" canuseraddrows="false" canuserdeleterows="true" canuserresizerows="false" canuserreordercolumns="false"> <datagrid.columns> <datagridtextcolumn binding="{binding name}" header="name"/> <datagridtextcolumn binding="{binding vseid}" header="vse id"/> <datagridtextcolumn binding="{binding imo}" header="imo"/> <datagridcomboboxcolumn selecteditembinding="{binding sitetype}" itemssource="{local:enumvalues rdsconfigconnector:sitetype}" header="site type"/> <datagridtextcolumn binding="{binding timeperiod}" header="fetching period"/> <datagridtextcolumn binding="{binding latitude}" header="latitude"/> <datagridtextcolumn binding="{binding longitude}" header="longitude"/> <datagridtextcolumn binding="{binding offsetlatitude}" header="offset latitude"/> <datagridtextcolumn binding="{binding offsetlongitude}" header="offset longitude"/> <datagridtemplatecolumn header="site owners"> <datagridtemplatecolumn.celltemplate> <datatemplate > <combobox itemssource="{binding owners.companies}"/> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> </datagrid.columns> </datagrid>
the data-context inside datatemplate
should site {binding owners.companies}
should work (see e.g. here).
aware data-binding case-sensitive => may shoudl {binding owners.companies}
?
if correct: did "binding error" in output window?
Comments
Post a Comment