0
我在製作WPF應用程序使用MahApps。它可以更改標題欄圖標以最小化,最大化並關閉窗口?我在網上搜索,但發現很少,但在尋找另一個解決方案之前,我想與你分享這個問題。更改MahApps MetroWindow中關閉按鈕的圖標
我有這個嘗試定製的,但不能更改圖標圖像
<Style x:Key="MetroWindowCloseButtonStyle"
TargetType="{x:Type Button}"
BasedOn="{StaticResource MetroWindowButtonStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="grid" Background="#000">
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="contentPresenter" Property="Opacity" Value="1" />
<Setter TargetName="grid" Property="Background" Value="#E04343" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="contentPresenter" Property="Opacity" Value=".5" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="grid" Property="Background" Value="#993D3D" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#ADADAD" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
它不可能性更改圖標?謝謝
出於好奇,如果您註釋掉ContentPresenter,該圖標是否消失? 如果確實如此,那麼建議您可以簡單地將自己的圖標放在按鈕內容中來更改圖標。 – Logan
[在Mahapps.Metro中設置WindowButtonCommands樣式]的可能重複(http://stackoverflow.com/questions/34563155/setting-windowbuttoncommands-styles-in-mahapps-metro) – punker76