Wpf 自定义倾斜窗口内的按钮不';不要总是得到鼠标事件
这是我的密码:Wpf 自定义倾斜窗口内的按钮不';不要总是得到鼠标事件,wpf,transform,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="Tr
<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>
当我将鼠标光标移动到按钮上时,有时它会获得焦点,有时则不会。如何使此自定义窗口中的按钮与常规窗口中的按钮类似 我认为您无法将转换应用于windows 您可以将它们应用于窗口内的控件
如果您需要模拟对windows的转换,您可以尝试类似于回答中所述的操作。可能会引发重复的异常:“转换对windows无效”。否,在我运行代码时不会引发异常。只是什么也没发生-窗口正常打开。抛出异常“Transform对窗口无效”。但它被吞没,不会使应用程序崩溃。如果检查输出窗口,您将看到PresentationFramework.dll中发生了“System.InvalidOperationException”类型的“first chance exception”。如果环绕
this.RenderTransform=ST代码>通过try/catch块执行。无论如何,您不能将转换应用于windows,请参见下面的我的答案。