person

person

  • NA
  • 96
  • 0

Dependency properties and bindings

Aug 5 2010 9:12 AM
Hi,

I have an object which has a property Day, which is a DayOfWeek (enum).

public Item()
{
    Day = DayOfWeek.Sunday;
}

I have bound this Day property to a bool[] (essentially) dependency property of a UserControl.

var week = new WeekField();
week.SetBinding(WeekField.WeekArrayProperty, TwoWayWithConverter(Item, "Day", dwwac));

dwwac - DayOfWeekToWeekArrayConverter. - basically takes a DayOfWeek and converts it into a bool[].

Now in the xaml :

<DataTemplate DataType="{x:Type vm:WeekSelectionField}">
                        <GroupBox Header="Week Selection" Margin="0,8,0,0">
                                     <userControls:ButtonsControl Value={Binding Path=WeekArray, Mode=TwoWay} />
                        </GroupBox>
</DataTemplate>


So i pass the dependencyproperty of WeekField to the Value DP of the ButtonsControl....the ButtonsControl simply has 7 radiobuttons, one for each day of the week.....

But now when I select a different radiobutton, none of properties are updated.
All classes implement INotifyPropertyChanged and I have written tests to confirm that this works.


I have also tried this by cutting out the WeekField and simply have the ButtonsControl, though it doesnt work either.

Thanks greatly in advance,

P.