2 Replies - 224 Views - Last Post: 23 October 2019 - 04:37 AM Rate Topic: -----

#1 ScottinTexas   User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 312
  • Joined: 13-March 12

Show selected date in WPF calendar control

Posted 22 October 2019 - 10:54 AM

I have a calendar with the Selected date bound to the NewDate property which is set when the user chooses x days from today. This works just fine except the calendar does not change to show the new date. The user can click on the arrow to the correct month and see the selected date, but the calendar will not automatically advance to the correct month. Does anyone know what has to be set to make it do what I want? This is a WPF MVVM project.

        <Viewbox Grid.Row="1"
                 Grid.Column="2"
                 Margin="5,0,5,0"
                 Stretch="Fill">
            <Calendar SelectedDate="{Binding NewDate}"
                      DisplayDateStart="1/1/2019"
                      DisplayDateEnd="12/31/2050">
            </Calendar>

        </Viewbox>




        public DateTime NewDate
        {
            get { return newDate; }
            set
            {
                newDate = value.AddDays(NumberOfDays);
                RaisePropertyChanged();
            }
        }



Thanks,

Is This A Good Question/Topic? 0
  • +

Replies To: Show selected date in WPF calendar control

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7143
  • View blog
  • Posts: 24,251
  • Joined: 05-May 12

Re: Show selected date in WPF calendar control

Posted 22 October 2019 - 06:52 PM

You also need to set the DisplayDate property.
Was This Post Helpful? 1
  • +
  • -

#3 ScottinTexas   User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 312
  • Joined: 13-March 12

Re: Show selected date in WPF calendar control

Posted 23 October 2019 - 04:37 AM

Perfect! :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1