views:

6

answers:

0

hello all, I an a newby and I spent over a day trying to figure it out how to update the observablecollection binded to a combobox. What I would like to do is to edit an item of a combobox, and then when I change the selection have it set as the current selected item and update the collection so that when I open the dropdown I see all remaining items unchanged. What I did was changing the selected item but the dropdown shows the old value. In other words I can't update the collection with the text inserted in the combo. this is what I have done

          <GridViewColumn >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Grid>
                                    <myComboBox Name="myPropCB" Text="{Binding Path=myProp}" IsTextSearchEnabled="False" IsEditable="True" SelectedItem="{Binding Path=myProp}" ItemsSource="{Binding Path=myPropColl}"/>
                                </Grid>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

in the code behind I intercept the combobox selectionchanged and set "myProp" to the entered string by forcing the update of the binding expression in my myComboBox derived class like this

   protected override void OnSelectionChanged(SelectionChangedEventArgs e)
    {
        base.OnSelectionChanged(e);

        BindingExpression exp = GetBindingExpression(ComboBox.TextProperty);
        if (exp != null)
        {
            expression.UpdateSource();
        }
     }

any help would be greatly appreciated!