0

I am using the Avalon DatePicker Control with MVVM pattern. I am binding this control's CurrentlySelectedDate to a property from my ViewModel like so:

<my:DatePicker x:Name="dtpBirthDate" Cursor="Hand" DatesSelectionMode="Single"   OverridesDefaultStyle="False"  CurrentlySelectedDate="{Binding Path=BirthDate}" />

where BirthDate is a property of type DateTime in my ViewModel class:

public DateTime BirthDate
    {
        get { return _patient.BirthDate; }
        set
        {
            if (value == _patient.BirthDate)
                return;

            _patient.BirthDate = value;

            base.OnPropertyChanged("BirthDate");
        }
    }

Still, the change of this property does not occur when I change the value from the user interface. Can someone explain me what I did wrong? I am restricted to .NET 3.0.

IonutC
  • 607
  • 1
  • 6
  • 11

2 Answers2

1

the solution was to add the UpdateSourceTrigger=PropertyChanged, Mode=TwoWay like so:

<my:DatePicker x:Name="dtpBirthDate" Cursor="Hand" DatesSelectionMode="Single"
                   OverridesDefaultStyle="False"
                   CurrentlySelectedDate="{Binding Path=BirthDate,    ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                   Validation.ErrorTemplate="{x:Null}"></my:DatePicker>
IonutC
  • 607
  • 1
  • 6
  • 11
0

Please, try to bind the BirthDate to the SelectedDate property instead of CurrentlySelectedDate.

Regards

Dan Delay
  • 102
  • 2
  • 12