在WPF/XAML中设置静态日期时间 [英] Setting a static datetime in WPF/xaml

查看:85
本文介绍了在WPF/XAML中设置静态日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试从后一天开始直到日期时间最大值停止日期时间选择器控件中的日期.

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

下面是代码:

    <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:

开始="{x:静态系统:DateTime.Today.AddDays(1)}"

能请你帮忙吗?

推荐答案

您可以为此创建自己的静态属性.

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}"…

这篇关于在WPF/XAML中设置静态日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆