Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何通过代码隐藏WinRT中的键盘_C#_Xaml_Windows Runtime_Keyboard - Fatal编程技术网

C# 如何通过代码隐藏WinRT中的键盘

C# 如何通过代码隐藏WinRT中的键盘,c#,xaml,windows-runtime,keyboard,C#,Xaml,Windows Runtime,Keyboard,在我的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="htt

在我的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>

尝试通过以下方式聚焦到另一个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;
        }
    }
子代(大型机).OfType().FirstOrDefault().Focus(FocusState.Pointer);
公共静态IEnumerable子代(DependencyObject根)
{
int count=VisualTreeHelper.GetChildrenCount(根);
for(int i=0;i
在我的例子中,我有一个带有几个文本框字段的表单。在其中一个例子中,我不希望应用程序显示数字键盘

为了防止出现这种情况,我指定了属性IsReadOnly=“True”

我使用IsReadOnly属性而不是IsEnabled=“False”,因为IsEnabled会禁用抽头事件,并且当我们在控件之间进行制表时,它不会停止

<TextBox Name="tbx" Style="{StaticResource TextBoxDefaultStyle}" TabIndex="13" IsReadOnly="True" />


您所说的“未按预期工作”是什么意思?我用上面的事件处理程序创建了一个文本框,当我点击Enter键时,控件被禁用,键盘被关闭。@DamirArh,但对我来说,键盘没有被关闭。此示例显示了当虚拟键盘出现时如何反应。我认为vibeeshanRC根本不想让它出现。乌尔是伊拉克的一座古城。不要发短信,在SO帖子中只链接答案。我们这里的标准很高;)
<TextBox Name="tbx" Style="{StaticResource TextBoxDefaultStyle}" TabIndex="13" IsReadOnly="True" />