0

I'm making a WPF app using MahApps . it can change the titlebar icons to minimize , maximize and close the window ? I searched online but found little about it , but before looking for another solution I wanted to share with you this question .

i have try custom with this, but not change the icon image

<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>

it possibile change icon ? thanks

Mr. Developer
  • 3,295
  • 7
  • 43
  • 110
  • Just out of curiosity, if you comment-out the ContentPresenter, does the icon disappear? If it does, that would suggest you can change the icon simply by putting your own icon inside the button's content. – Logan Jan 20 '16 at 16:37
  • 1
    Possible duplicate of [Setting WindowButtonCommands styles in Mahapps.Metro](http://stackoverflow.com/questions/34563155/setting-windowbuttoncommands-styles-in-mahapps-metro) – punker76 Jan 21 '16 at 21:22
  • Possible duplicate of [Customizing Mahapps.MetroWindow Close Button](https://stackoverflow.com/questions/23749094/customizing-mahapps-metrowindow-close-button) – Christoffer Lette Apr 10 '19 at 12:30

1 Answers1

1

The same question was asked at Github a couple of days ago. punker76 described the solution in a comment.

Community
  • 1
  • 1
Thomas Freudenberg
  • 5,048
  • 1
  • 35
  • 44