自定义倾斜窗口内的按钮并不总是获得mouseEnter事件

时间:2014-01-01 13:57:53

标签: wpf transform

这是我的代码:

 <Window x:Class="WPFStackOverFlow.SkewWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    AllowsTransparency="True" WindowStyle="None" Background="Transparent"
    Title="MainWindow" Height="600" Width="687">

<Border BorderBrush="Green" BorderThickness="2" Background="White" Width="360" Height="360">
    <Border.RenderTransform>  
        <SkewTransform AngleX="-23" AngleY="10"></SkewTransform>
    </Border.RenderTransform>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="23" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button Grid.Row="0" Content="X" Width="23" Name="button1" HorizontalAlignment="Right" Click="button1_Click" Height="23" VerticalAlignment="Bottom"/>
        <Grid Grid.Row="1">
            <Button Height="100" Width="200"></Button>
            <TextBlock Text="Some very very long Text" HorizontalAlignment="Center"/>
        </Grid>
    </Grid>
</Border>

当我将鼠标光标移动到按钮上时,它有时会获得焦点,有时则不会。如何使此自定义窗口中的按钮像常规窗口中的按钮一样?

1 个答案:

答案 0 :(得分:0)

我认为您不能将转换应用于Windows。

您可以将它们应用于窗口内的控件。

如果您需要模拟转换到窗口,您可以尝试类似于this question的答案中描述的内容。