I have a problem regarding the DatePicker from the ToolBox. I'm trying to create a program in WPF for a user to choose two dates from two DatePickers, and based on these dates determine the amount of days between them.
Online I found another typ of tool called DateTimePicker, which seems easier to use. However, this is not included in my ToolBox so I'm forced to use the DatePicker-class.
So far my cs-code looks like below.
using System;
using System.Collections.Generic;
namespace DateDifference
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        public static object RadDatePickerStart { get; private set; }
        private void button_Click(object sender, RoutedEventArgs e)
        {
        }
        private void startDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            // ... Get DatePicker reference.
            var picker = sender as DatePicker;
            // ... Get nullable DateTime from SelectedDate.
            DateTime? date = picker.SelectedDate;
            if (date == null)
            {
                // ... A null object.
                this.Title = "No date";
            }
            else
            {
                // ... No need to display the time.
                this.Title = "Program for calculating difference between dates";
                textBoxResult.Text = date.Value.ToShortDateString();
            }
        }
        private void endDate_SelectedDateChanged_1(object sender, SelectionChangedEventArgs e)
        {
            // ... Get DatePicker reference.
            var picker = sender as DatePicker;
            // ... Get nullable DateTime from SelectedDate.
            DateTime? date = picker.SelectedDate;
            if (date == null)
            {
                // ... A null object.
                this.Title = "No date";
            }
            else
            {
                // ... No need to display the time.
                this.Title = "Program for calculating difference between dates";
                textBoxResult.Text = date.Value.ToShortDateString();
            }
        }
    }
}
So my question is how to get the difference in days with this DatePicker-class?
Best regards!
 
    