Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a static datetime in WPF/xaml

Tags:

c#

wpf

I'm trying to blackout dates in my datetime picker control starting from day after today till datetime max value.

The below is the code:

    <Calendar.BlackoutDates>
        <CalendarDateRange Start="{x:Static System:DateTime.Today}"
 End="{x:Static System:DateTime.MaxValue}" />
    </Calendar.BlackoutDates>

As you could see, the above code will blackout dates starting from today, but I want the start date from tomorrow. Basically the question is, how can I set something like this:

Start="{x:Static System:DateTime.Today.AddDays(1)}"

Could you please help?

like image 347
Mike Avatar asked May 09 '13 13:05

Mike


1 Answers

You can create your own static property for this.

  public static class DateTimeHelper
  {
    public static DateTime Tomorrow
    {
      get { return DateTime.Today.AddDays(1); }
    }
  }

.

  <CalendarDateRange Start="{x:Static app:DateTimeHelper.Tomorrow}"…
like image 89
Jay Avatar answered Sep 28 '22 11:09

Jay