GRID DATEPICKER COLUMN - WIDTH OF DATEPICKER POPUP

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C# 
C#
 1121  View(s)
Ratings:
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. Pravesh Singh

    Post:412

    Points:2888
    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.

    root.Children.Add(datePickerFor2009);

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!