我有一个看起来像这样的窗口:
<vk:VirtualKeyboard x:Class="Hurst.VirtualKeyboard.QwertyVirtualKeyboard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:vk="clr-namespace:Hurst.VirtualKeyboard"
xmlns:vm="clr-namespace:Hurst.VirtualKeyboard.ViewModels"
DataContext="{DynamicResource keyboardViewModel}"
Height="400" Width="1280" d:DesignHeight="300" d:DesignWidth="710"
x:Name="VK"
>
<vk:VirtualKeyboard.Resources>
<ObjectDataProvider x:Key="keyboardViewModel" ObjectType="{x:Type vm:KeyboardViewModel}" />
</vk:VirtualKeyboard.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="43"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="0" Foreground="White" Margin="0 3 20 0" Background="#006AB6" BorderThickness="0" Command="{Binding CloseKeyboardCommand}" FontSize="25" Content="Close" VerticalContentAlignment="Center"/>
<Border Grid.Row="1" BorderBrush="#006AB6" BorderThickness="5">
some content here
</Border>
</Grid>
QwertyVirtualKeyboard是一个扩展VirtualKeyboard类的类,它扩展了Window类。
我面临的问题是:当我点击“关闭”按钮时,有时会触发“关闭”命令,有时不会触发。悬停时会发生同样的事情 - 有时会触发悬停,有时则不会。我注意到当鼠标位于按钮的底部时,悬停并单击它们应该工作,但当我将鼠标移动到按钮的上半部分时,它们不会。我在这里缺少什么?