Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3160
Binding to viewmodel property does not work
posted

I have a usercontrol which is basically a combobox in an unbound field in my xamdatagrid.  I need to bind the Items to a list which exists on my viewmodel i.e. DataContext.AssetClasses.
I also need to bind SelectedItems to a property of the class the datagrid is bound too. 

 

 <igDP:UnboundField Name="JunkAssetClasses" Label="Asset Classes">
                                                    <igDP:Field.Settings>
                                                        <igDP:FieldSettings>
                                                            <igDP:FieldSettings.CellValuePresenterStyle>
                                                                <Style TargetType="{x:Type igDP:CellValuePresenter}">
                                                                    <Setter Property="Template">
                                                                        <Setter.Value>
                                                                            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                                                                                <controls:MultiCombo
                                                                                    Items="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.AssetClasses}"
                                                                                    SelectedItems="{Binding JunkAssetClasses}">
                                                                                </controls:MultiCombo>
                                                                            </ControlTemplate>
                                                                        </Setter.Value>
                                                                    </Setter>
                                                                </Style>
                                                            </igDP:FieldSettings.CellValuePresenterStyle>
                                                        </igDP:FieldSettings>
                                                    </igDP:Field.Settings>
                                                </igDP:UnboundField>

 

For reference,  I was using XamMultiColumnComboEditor and it was bound as follows (same as above but in bound field) and it worked:
<ig:XamMultiColumnComboEditor
  ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.AssetClasses}"