views:

24

answers:

0

Hello, everyone. I fell in the following situation: I have a main UserControl with a DataGrid (which contains List). I need to show different panels depending on properties of the selected row(object). So i've created 2 controls and included them into this main control. Main control has 2 public properties -

public List<ComplexObject> SourceList { get; set; } 

and

public ComplexObject CurrentObject { get; set; }

Pseudo-code:

<UserControl x:Name="Main">
     <DataGrid ItemsSource="{Binding SourceList}" SelectedItem="{Binding CurrentObject, Mode=TwoWay}"/>
     <Controls:RightPanelFirst Visibility="condition2"/>
     <Controls:RightPanelSecond Visibility="condition2"/>
</UserControl>

RightPanelFirst and RightPanelSecond have the following xaml:

<UserControl>
    <... content here...>
    <CheckBox IsChecked="{Binding CurrentObject.ComplexProperty.SimpleProperty1, Mode=TwoWay}">
    <CheckBox IsChecked="{Binding CurrentObject.ComplexProperty.SimpleProperty2, Mode=TwoWay}" x:Name="cbSecond">
    <TextBox IsEnabled="{Binding IsChecked, ElementName=cbSecond}"/>
</UserControl>

So, my actual steps:

  1. Check both checkboxes (object values are set to true)
  2. Make other actions in code behind which modify CurrentObject.
  3. Then i want UI to reflect the changes, so I call NotifyPropertyChanged("CurrentObject");
  4. SimpleProperty1 remains the same, but SimpleProperty2 resets to false

I have no idea why this happens, can anyone help me please? Silverlight drives me mad.

Edit. Forgot to mention that, the second panel contains radiobuttons with bindings and one of the bindings is the same SimpleProperty2.