tags:

views:

487

answers:

3

I am trying to bind a ComboBox to data from an object. The object holds a list that is the allowed states and a string that represents its current value. The problem I'm having is that when the form loads it correctly sets the value of the combobox to its current value but I am unable to change the value to anything else. If I click the dropdown and choose a new value it closes the dropdown but retains the original value.

The comboboxs are each in a row in a DataGrid and the ComboBox is contained in the RowDetailsTemplate for the DataGrid.

XAML:

<ComboBox
   x:Name="cmbStatus"
   ItemsSource="{Binding Path=AllowedStateValues}"
   SelectedItem="{Binding Path=State}"    
   Height="20"
   Width="100" />
A: 

State decleration:

private string _state;
    public string State { 
        get { return _state; }
        set
        {
            if (AllowedStateValues != null && AllowedStateValues.Contains(value))
            {
                _state = value;

            }
        }

    }

I don't have an event being raised when it is changed but it also appears to not calling the setter when you change the combobox

Stephan
+1  A: 

Try setting binding Mode to TwoWay. If that does not work, use PresentationTraceSources.TraceLevel property to High, to get full details.

orca
I tried Mode=TwoWay and get no change. I'm not sure what PresentationTraceSources.TraceLevel="High" is supposed to accomplish.
Stephan
It will do nothing but trace all important information regarding the binding set. There might be a hint towards the source of the problem.
orca
A: 

I just had the same problem. Turns out my issue was in my Equals override of the items being bound. Check and make sure that more than one object that are not equal are not being compared as equal.

Mark Lindell