我有一个日期选择器,但它允许我输入任何文本。我想禁止用户输入文本。应该允许用户从日历中选择日期。
<Window x:Class="MyTestForDatePicker.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<!--<Grid>-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<DatePicker Grid.Column="0" Grid.Row="0" Margin="2" Name="MySelectedDate" VerticalContentAlignment="Center" ></DatePicker>
<DatePickerTextBox Grid.Column="1" Grid.Row="3" Margin="2" Name="SelectedDate" IsReadOnly="True"></DatePickerTextBox>
<Button Grid.Column="1" Grid.Row="1" Margin="100,102,203,154" VerticalContentAlignment="Center" Name="Ok" Click="Ok_Click_1"/>
</Grid>