我正在尝试模拟按钮事件中的按键操作。我可以使用下面的代码来模拟一些键,例如Backspace,但Enter不起作用。
我究竟做错了什么?
private void btnEnter_Click(object sender, RoutedEventArgs e)
{
tbProdCode.Focus();
KeyEventArgs ke = new KeyEventArgs(
Keyboard.PrimaryDevice,
Keyboard.PrimaryDevice.ActiveSource,
0,
Key.Enter)
{
RoutedEvent = UIElement.KeyDownEvent
};
InputManager.Current.ProcessInput(ke);
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个新的wpf窗口并设置了主网格的背景,当我将WindowStyle设置为None时,发现窗口顶部有一个空白区域。如何删除空格?
<Window x:Class="XuanyiRetail.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" WindowStyle="None">
<Grid Background="Bisque">
</Grid>
Run Code Online (Sandbox Code Playgroud)