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
920
Show combobox inside the grid using MVVM
posted

Hi,

   My question is similar to the question on this thread https://ko.infragistics.com/community/forums/t/34846.aspx.

I studied the sample code sample download from the thread and applied it to my solution with changes to obsoleted segments and I cant get it to work. The comboboxes are not showing up. Please help.

Here is my code 

<igDP:Field BindingType="UseAlternateBinding" AlternateBinding="{Binding Path=SelectedCity, Mode=TwoWay}" Label="{x:Static localization:ManagerParameters.ModificationLabel}" Visibility="Visible">
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsSource" Value="{Binding DataPresenter.DataContext.Cities}"/>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>

Thanks,

Lala

  • 6365
    Verified Answer
    Offline posted

    Hello Lala,

    Thank you for the code-snippet and the thread reference you have provided.

    When the DataItem class (in our case MyClass) contains a child collection, this collection will be displayed as another child layout in the XamDataGrid by default. Since we would like to visualize the items of this collection within a XamComboEditor (instead of in another layout), we can manually disable the visibility of the corresponding field for the collection (the Cities field) and create a new ComboBoxField that is bound the the underlying Cities collection of every MyClass instance.

    XAML:


    <igDP:Field Name="Name" />

    <!-- Displays with additional layout by default -->
    <igDP:Field Name="Cities" Visibility="Collapsed" />

    <igDP:ComboBoxField Label="Cities Combo" BindingType="Unbound">
      <igDP:ComboBoxField.Settings>
        <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
          <igDP:FieldSettings.EditorStyle>
            <Style TargetType="{x:Type igEditors:XamComboEditor}">
              <Setter Property="ItemsSource" Value="{Binding DataItem.Cities}"/>
            </Style>
          </igDP:FieldSettings.EditorStyle>
        </igDP:FieldSettings>
      </igDP:ComboBoxField.Settings>
    </igDP:ComboBoxField>

    I have attached a sample application that demonstrates the approach from above.

    If you have any questions, please let me know.

    XamDataGrid_sample.zip