当用户悬停“mybutton”时,我试图让窗口框架出现。这应该有效,但由于某种原因它不是。我错过了什么?
<Window x:Class="test2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" WindowStyle="None" Loaded="ShellWindow_SourceInitialized" x:Name="mywindow">
<Window.Resources>
<Style TargetType="{x:Type Window}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=mybutton}" Value="True">
<Setter Property="ResizeMode" Value="CanResize" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, ElementName=mybutton}" Value="False">
<Setter Property="ResizeMode" Value="NoResize" />
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid Name="mygrid" Loaded="Grid_Loaded">
<Button Name="mybutton" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"/>
</Grid>
(如果您想知道那些“已加载”功能是什么,它们会在保留阴影的同时删除 chrome 并允许透明度 = false http://marcin.floryan.pl/blog/2010/08/wpf-drop-shadow-with-windows -dwm-api)最后它不会是按钮,而是会在整个窗口边框上做出反应(我找不到更好的方法来启用调整大小,同时删除所有 chrome)