0
我正在WPF中創建自定義窗口樣式。到目前爲止,我已經能夠在純XAML中完成幾乎可以工作的內容。WPF中的自定義標題按鈕
<ControlTemplate TargetType="{x:Type Window}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<DockPanel LastChildFill="True">
<Border Height="40" Padding="5" DockPanel.Dock="Top" BorderBrush="#7FA0A0A0"
BorderThickness="0,0,0,1">
<Grid WindowChrome.IsHitTestVisibleInChrome="True">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Image Source="Resources/Logo/f-dark.png" />
<TextBlock Margin="0,0,0,0" Text="{TemplateBinding Title}" VerticalAlignment="Center"
FontSize="16" Foreground="#AF000000"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"
WindowChrome.IsHitTestVisibleInChrome="True" Background="Transparent">
<Button Width="{x:Static SystemParameters.WindowCaptionButtonWidth}"
Command="{x:Static SystemCommands.MinimizeWindowCommand}"
Style="{StaticResource LinkButton}"
WindowChrome.IsHitTestVisibleInChrome="True"
IsEnabled="True">
<TextBlock Style="{StaticResource Icon}" FontSize="18"></TextBlock>
</Button>
<Button Width="{x:Static SystemParameters.WindowCaptionButtonWidth}"
Command="{x:Static SystemCommands.RestoreWindowCommand}"
Style="{StaticResource LinkButton}"
WindowChrome.IsHitTestVisibleInChrome="True"
IsEnabled="True">
<TextBlock Style="{StaticResource Icon}" FontSize="18"></TextBlock>
</Button>
<Button Width="{x:Static SystemParameters.WindowCaptionButtonWidth}"
Command="{x:Static SystemCommands.CloseWindowCommand}"
Style="{StaticResource LinkButton}"
WindowChrome.IsHitTestVisibleInChrome="True"
IsEnabled="True">
<TextBlock Style="{StaticResource Icon}" FontSize="18"></TextBlock>
</Button>
</StackPanel>
</Grid>
</Border>
<Border>
<ContentPresenter/>
</Border>
</DockPanel>
</Border>
</ControlTemplate>
然而,在該窗口鍍鉻按鈕不突出或改變光標(和按鍵使用相同的風格表現爲意)。點擊它們不起作用。爲什麼是這樣?我如何獲得按鈕是互動的?
我也想能夠修復的黑邊,但我的主要問題是,標題按鈕非交互。