Assigning datasource to combo box in flexgrid with ViewModel in MVVM

Posted by: haim on 12 January 2020, 1:35 am EST

    • Post Options:
    • Link

    Posted 12 January 2020, 1:35 am EST

    I would like to place a combobox in a flexgrid that’s bound to an entity. I would like to do it in the viewmodel using the MVVM pattern, but I can’t find a dependency property that I can bind to. At present the only way I can do this is in the code behind.

    My XAML

    <c1:C1FlexGrid.Columns>
                    <c1:Column Binding="{Binding shortname}" Header ="מחלקה" Width="100"/>
                    <c1:Column Binding="{Binding fullname}" Width="150"/>
                    <c1:Column Binding="{Binding Eshortname}" Width="100" Header="English"/>
                    <c1:Column Binding="{Binding Instituteid}" Width="50" Header="מכון" />
                </c1:C1FlexGrid.Columns>
    
    

    my code behind:

    this.deptfg.Columns["Instituteid"].ValueConverter =  new ColumnValueConverter(institutes, "id", "shortname");
    

    Is there another to do this using the MVVM pattern? Should I use another control?

    Haim Katz

  • Posted 12 January 2020, 11:27 pm EST

    Hello Haim,

    You can instead set Column’s CellTemplate and inside use Combobox, as follows:```

    <c1:Column Binding=“{Binding InstituteId}” Width=“50” Header=“Inst.ID”>

    c1:Column.CellTemplate







    </c1:Column.CellTemplate>

    </c1:Column>

    Ruchir
    [zip filename="ComboboxDS_C1FlexGrid.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-7beb6cf7-2ac8-44e0-898c-3e724ac33282.zip[/zip]
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels