简体   繁体   English

如何从代码后面打开日期选择器的日历?

[英]How to open the calendar of the datepicker from code behind?

I'm using WPF and C# to develop my application. 我正在使用WPF和C#来开发我的应用程序。 In my application, i have two datepicker. 在我的应用程序中,我有两个datepicker。 The first datepicker required user to choose the Depart date and the second calendar require user to choose the Return date. 第一个datepicker要求用户选择离开日期,第二个日历要求用户选择返回日期。 So what i want to do is, after user choose the depart date, the calendar from the second datepicker will open up. 所以我想要做的是,在用户选择离开日期后,第二个日期选择器的日历将打开。 May i know what is the event to open up the calendar? 我可以知道打开日历的活动是什么?

 <DatePicker Name="departDate" SelectedDateChanged="departDate_SelectedDateChanged">   
 <DatePicker Name="returnDate" >

C# code snippet C#代码段

private void departDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
    //returnDate.calendarOpen??
}

I found the answer, use the isDropDownOpen : 我找到了答案,使用isDropDownOpen:

private void departDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
   returnDate.isDropDownOpen = true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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