在我的 winRT C# 应用程序中,我有一个文本框,当文本框被禁用时,可视键盘必须隐藏。但它没有按预期工作。
<Page
x:Class="App2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<TextBox HorizontalAlignment="Left" Margin="458,60,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Height="98" Width="389" KeyUp="TextBox_KeyUp_1"/>
</Grid>
C#
private void TextBox_KeyUp_1(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Enter)
(sender as TextBox).IsEnabled = false;
}