-1

I have created a calenderview in winui3 for my project. I am setting the selected date in the code behind file. But the calendar is not bringing the selected date into view. How to fix this? enter image description here

If I set the selected date which is not present in this view in the code behind file like below

MyCalendar.SelectedDates.Add(someDate);

After adding the selectedate it is not brought into the view. Should we do it explicitly ?

1
  • Hi @Bevara Satyasairam. I'm not sure but adding the XAML and the codebehind setting the date might help this question to be reopened again. Commented Sep 15 at 2:35

1 Answer 1

0

You can use SelectedDatesChanged and SetDisplayDate for this:

MyCalendar.SelectedDatesChanged += MyCalendar_SelectedDatesChanged;
private void MyCalendar_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
{
    if (args.AddedDates.Count < 1)
    {
        return;
    }

    sender.SetDisplayDate(args.AddedDates[0]);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.