0

I have simple WPF application, and I need to let user choose value from Calendar and then work with the day only. For example, user chooses date 06/08/2020, so I need to take the "06" value and assign it to double variable, then work with it in some mathematical equations.

Unfortunately I did not find on the interner, how to exactly do it. When the user enters number into textbox, its quiet easy, you just state the variable and put the TextBox.Text as a value, like double x = double.Parse(TextBox1.Text);

Can you guys help me on this?

Laufrech
  • 3
  • 2
  • Don't use the text. The datepicker has a DateTime type property - SelectedDate. Work with that. You can extract day, month, year etc out of a datetime easily. eg int day = dp.SelectedDate.Day; Day is day of month and it's an int. Double doesn't make any sense. What's today's date? 16.3 ? No. It's the 16th. – Andy Aug 16 '20 at 10:21
  • Thanks, that is right, int makes more sense. So I have name of the calendar ,,Calendar1,,. The code should look something like this then? int day = Calendar1.SelectedDate.Day;? Tried some variations, but none of them is working. – Laufrech Aug 16 '20 at 10:41

0 Answers0