C# wpf calendar choose dates

I am trying to implement a basic project in C# wpf . I would like to choose dates from a calendar and these dates to appear on the screen.
i use the component calendar from toolkit with the code :

 private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)

Open in new window

i did a google search and i find that with the code something like

 private void Calendar_SelectedDatesChanged(object sender,
            SelectionChangedEventArgs e)
            // ... Get reference.
            var calendar = sender as Calendar;

            // ... See if a date is selected.
            if (calendar.SelectedDate.HasValue)
                // ... Display SelectedDate in Title.
                DateTime date = calendar.SelectedDate.Value;
                this.Title = date.ToShortDateString();

Open in new window

the problem is that if i use calendar.Selected then an error appear .

How to solve this? Also can i find good reference for beginner in C#?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technical NinjaCommented:
Hi Gas,

It is always a good practice to provide the exact error details. Also I think there is a typo in your question. calendar.Selected? or calendar.SelectedDate?

And to learn C# I strongly recommend the following 2 books
1. https://www.microsoftpressstore.com/store/exam-ref-70-483-programming-in-c-sharp-9781509306985 - I have used this one personally and though it is bit certification oriented, I loved the author simplifies C# concepts.
2. https://www.microsoftpressstore.com/store/microsoft-visual-c-sharp-step-by-step-9781509307760 - I have not read this one, but have heard good reviews from colleagues/friends.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.