WPF InputScope无法在Dialoghost.NET 6上工作



我有一个带文本框的dialogHost,由于使用了触摸键盘,我需要将输入范围设置为数字,在用户控件中它可以正常工作,但在对话框中键盘布局不变。

<materialDesign:DialogHost x:Name="dgh_addProduct" CloseOnClickAway="True" IsOpen="{Binding AddProduct}" Grid.RowSpan="4" >
<materialDesign:DialogHost.DialogContent>
<StackPanel Background="{DynamicResource MaterialDesignPaper}">
<TextBox  materialDesign:HintAssist.Hint="Cantidad" BorderThickness="2"
BorderBrush="{DynamicResource MaterialDesignDivider}"
Style="{StaticResource MaterialDesignOutlinedTextBox}" Width="200" Margin="16"
PreviewTextInput="TextBoxNumeric_PreviewTextInput" InputScope="Number" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="16">
<Button Style="{StaticResource MaterialDesignFlatDarkBgButton}"
Background="Red" BorderBrush="Transparent" Content="Close" Width="100"
Command="{Binding CloseAddProductCommand}"  Margin=" 8 0 16 0"/>
<Button  Style="{StaticResource MaterialDesignFlatAccentBgButton}"
BorderBrush="Transparent" Content="Agregar" Width="100"
Command="{Binding CloseAddProductCommand}" Margin=" 16 0 8 0"/>
</StackPanel>

</StackPanel>
</materialDesign:DialogHost.DialogContent>

</materialDesign:DialogHost>

我找到了将嵌入式样式添加到对话框主机的解决方案,如下所示:

<materialDesign:DialogHost x:Name="dgh_addProduct" CloseOnClickAway="True" IsOpen="{Binding AddProduct}"
Grid.RowSpan="4" Style="{StaticResource MaterialDesignEmbeddedDialogHost}">
<materialDesign:DialogHost.DialogContent>
<StackPanel Background="{DynamicResource MaterialDesignPaper}">
<TextBox  materialDesign:HintAssist.Hint="Cantidad" BorderThickness="2"
BorderBrush="{DynamicResource MaterialDesignDivider}"
Style="{StaticResource MaterialDesignOutlinedTextBox}" Width="200" Margin="16"
PreviewTextInput="TextBoxNumeric_PreviewTextInput" InputScope="Number" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="16">
<Button Style="{StaticResource MaterialDesignFlatDarkBgButton}"
Background="Red" BorderBrush="Transparent" Content="Close" Width="100"
Command="{Binding CloseAddProductCommand}"  Margin=" 8 0 16 0"/>
<Button  Style="{StaticResource MaterialDesignFlatAccentBgButton}"
BorderBrush="Transparent" Content="Agregar" Width="100"
Command="{Binding CloseAddProductCommand}" Margin=" 16 0 8 0"/>
</StackPanel>

</StackPanel>
</materialDesign:DialogHost.DialogContent>

</materialDesign:DialogHost>

现在它可以识别输入范围并更改触摸键盘布局。

相关内容

  • 没有找到相关文章

最新更新