解决:我使用了Calendaer_Closed Eevent 但为什么申请卡住了我不知道 也许是因为它正处于改变事件的某个动作中间
当我从DatePicker
中选择日期时,我尝试关闭菜单并冻结我的应用程序
这是我的代码:
<Window x:Class="WpfApplication9.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication9"
Title="MainWindow" Width="500" Height="500">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
</Window.Resources>
<StackPanel>
<Menu Height="40" >
<MenuItem Header="First" x:Name="_menuItem">
<MenuItem Header="Date" StaysOpenOnClick="False">
<MenuItem StaysOpenOnClick="False" >
<MenuItem.Header>
<DatePicker SelectedDateChanged="DatePicker_SelectedDateChanged"/>
</MenuItem.Header>
</MenuItem>
</MenuItem>
</MenuItem>
</Menu>
<Button x:Name="btn" Content="click" />
</StackPanel>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
_menuItem.IsSubmenuOpen = false;
}
}