0

Working with the MahApps.Metro package and would like to handle the click event of the windows Icon so that I can show the user a Flyout with a application menu, does anyone know how this could be achieved, I cannot see any obvious events on the MetroWindow object to support this?

Neil Stevens
  • 3,534
  • 6
  • 42
  • 71

1 Answers1

3

Create a new Template for the Icon and set it as IconTemplate="{DynamicResource DataTemplate1}" in MetroWindow.

<Controls:MetroWindow.Resources>
    <DataTemplate x:Key="DataTemplate1">
            <Button  Click="Button_Click">
                <Button.Template>
                    <ControlTemplate TargetType="Button">
                        <Image  Source="Icon.ico" />
                    </ControlTemplate>
                </Button.Template>
            <Button.ContextMenu>
                <ContextMenu>
                    <Menu>
                        <MenuItem Header="Nonsense"/>
                    </Menu>
                </ContextMenu>
            </Button.ContextMenu>
        </Button>                   
    </DataTemplate>
</Controls:MetroWindow.Resources>

Handle the Click event of the Button.

AnjumSKhan
  • 9,647
  • 1
  • 26
  • 38