简体   繁体   中英

How to change the default “today” date in the WPF Calendar control?

Is there a way to change the current date to some date other then today in the standard WPF Calendar control?

Using the below bindings (VS 2010) for an MVVM project, the month being displayed correctly aligns with the DisplayDate. However, the grayed out date representing "today" remains the same and only grays out when the calendar is moved to the same month as "today" resides in.

  <Calendar SelectedDate="{Binding RTO.SelectedDate}" 
            DisplayDate="{Binding Path=RTO.DisplayDate}"
            Margin="151,122,0,0" 
            VerticalAlignment="Top" 
            Width="205" />

What I would like to do is change the current date of the calendar in the viewmodel from its default of DateTime.Today to some other date. Can this be done? (I'd like the SelectedDate to remain whatever the user selects. That is, the selecteddate is not necessarily the current date).

(If this is a duplicate question, I apologize. But everything I've googled seems to use the selecteddate as the "currentdate").

Please add IsTodayHighlighted="False" attribute to the control. Hope it will work.

http://www.c-sharpcorner.com/UploadFile/mahesh/wpf-datepicker/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM