1

私の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;
        }
4

3 に答える 3

0

これがサンプルコードです。コードと照合して確認できます

于 2013-01-01T12:42:25.173 に答える
0

これを介して別の UIElement にフォーカスしてみてください:

    Descendents(MainFrame).OfType<Button>().FirstOrDefault().Focus(FocusState.Pointer);


    public static IEnumerable<DependencyObject> Descendents(DependencyObject root)
    {
        int count = VisualTreeHelper.GetChildrenCount(root);
        for (int i = 0; i < count; i++)
        {
            DependencyObject child = VisualTreeHelper.GetChild(root, i);
            yield return child;
            foreach (DependencyObject descendent in Descendents(child))
                yield return descendent;
        }
    }
于 2013-07-16T10:53:03.207 に答える