none
How to bind collection to DataGridComboBoxColumn RRS feed

  • General discussion

  • Hello,


    I want to bind DataGrid to collection of objects which have a field of type ObservableCollection<string> (named Subs) which I would like to bind to DataGridComboBoxColumn

            <my:DataGrid Margin="8,9,6,69" Name="filmsGrid" AutoGenerateColumns="False" >
                <my:DataGrid.Columns>
                    <my:DataGridComboBoxColumn ItemsSource="{Binding Path=Subs, Converter={StaticResource TestConverter}}" ></my:DataGridComboBoxColumn>
                </my:DataGrid.Columns>
            </my:DataGrid>

    The strange thing is that data are not going to ItemsSource (my TestConverter Convert method is not triggered).

    I also tried to use DataGridTemplateColumn like this:

            <DataTemplate x:Key="ComboTemplate">

                <ComboBox   ItemsSource="{Binding Path=Subs, Mode=OneTime, Converter={StaticResource TestConverter}}" ></ComboBox>

            </DataTemplate>

    I almost  works because even with Mode set to OneTime the ItemSource is set when I’m scrolling a grid (binding is refreshed and selection on comboboxes is cleared).

     

    Any ideas on how to simply bind this collection to ComboBox column one time and refresh it sometimes but not when scrolling the control (for instance when I update my source)??

    • Changed type Marco Zhou Friday, November 14, 2008 8:23 AM OP doesn't revert back
    Wednesday, November 12, 2008 12:09 PM

All replies