Grid DatePicker Column - Width of DatePicker Popup

Total Post:154

 1448  View(s)
Rate this:

I have a WPF-Grid and a Column with a DatePicker (Windows.Controls.DatePicker). I tried to set the Width/Height of the DatePicker Popup Programmatically.

I want to set the with in my C# Code (not in the xaml). Has someone a idea how i can do this? Is this possible?
  1. Post:412

    Re: Grid DatePicker Column - Width of DatePicker Popup

    Hi Manoj,

    I take it you are not following the MvvM pattern to achieve desired result.

    If you want to set it programmatically you can do it in the constructor of your view and basically do this:

    DatePicker datePickerFor2009 = new DatePicker();
    datePickerFor2009.SelectedDate = new DateTime(2009, 3, 23);
    datePickerFor2009.DisplayDateStart = new DateTime(2009, 1, 1);
    datePickerFor2009.DisplayDateEnd = new DateTime(2009, 12, 31);
    datePickerFor2009.SelectedDateFormat = DatePickerFormat.Long;
    datePickerFor2009.FirstDayOfWeek = DayOfWeek.Monday;
    datePickerFor2009.Height = (double)desiredHeight;
    datePickerFor2009.Width = (double)desiredWidth;
    // root is a Panel that is defined elsewhere.

      Modified On Apr-04-2018 02:09:46 AM