Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to implement double click event on Title bar for maximize and minimize the window

XML
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xml:lang="en-US"
    xmlns:abc="clr-namespace:abc"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2006"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:local="clr-namespace:abc"
    x:Class="abc.Window1"
    x:Name="Window"
    Title="Good People"
    MinHeight="100"
    MinWidth="200" AllowsTransparency="True" Background="Transparent" SizeChanged="Window_SizeChanged"
    Height="600" Width="900" WindowStyle="None" Loaded="Window_Loaded" PreviewMouseMove="ResetCursor"
    ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Icon="/abc;component/aexe.ico" PreviewKeyDown="Window_PreviewKeyDown" MouseLeftButtonDown="Window_MouseDown">
    <Border Name="windowborder1" BorderBrush="{DynamicResource MyDarkBlueSolidBrush}" Background="{DynamicResource TitleBorderBrush}" BorderThickness="1.5" CornerRadius="5">
        <Border Name="windowborder" BorderBrush="{StaticResource TitleBorderBrush}" Background="{StaticResource TitleBorderBrush}" BorderThickness="2" CornerRadius="5" >
            <Grid x:Name="LayoutRoot">

                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" VerticalAlignment="Top" Height="2.5" x:Name="top" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Margin="2.5,0,2.5,0"/>
                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" x:Name="bottom" Height="2.5" VerticalAlignment="Bottom" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Margin="2.5,0,2.5,0"/>
                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" HorizontalAlignment="Left" Margin="0,2.5,0,2.5" Width="2.5" x:Name="left" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor"/>
                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" Margin="0,2.5,0,2.5" Width="2.5" HorizontalAlignment="Right" x:Name="right" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" />
                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="2.5" Height="2.5" x:Name="bottomLeft" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor"/>
                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" VerticalAlignment="Bottom" Height="2.5" Width="2.5" HorizontalAlignment="Right" x:Name="bottomRight" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor"/>
                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" HorizontalAlignment="Right" Width="2.5" Height="2.5" VerticalAlignment="Top" x:Name="topRight" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor"/>
                    <Rectangle Fill="{StaticResource TitleBorderBrush}" Stroke="{x:Null}" HorizontalAlignment="Left" Width="2.5" VerticalAlignment="Top" Height="3" x:Name="topLeft" PreviewMouseLeftButtonDown="Resize"  MouseMove="DisplayResizeCursor"/>

                    <!-- Top PANEL -->

                    <DockPanel Name="Maindocpanal" Background="{DynamicResource TitleBorderBrush}" Margin="2.5,2.5,2.5,2.5">
                        <!-- TITLE BAR  -->
                        <Grid Height="auto" Name="gridTitle" Width="auto" DockPanel.Dock="Top" MouseLeftButtonDown="mouseLeftButtonDown" Margin="0,0,0,0">
                            <!-- TITLE BAR -->
                            <Grid Name="maxMinCloseGrid"  Height="auto" Background="{DynamicResource TitleBorderBrush}"
                                ClipToBounds="False" Margin="0,0,0,0" IsHitTestVisible="True">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition  Width=".300*" />
                                    <ColumnDefinition Width=".700*" />
                                </Grid.ColumnDefinitions>

                                <Label Margin="105,5,0,1" Name="titleLabel" DockPanel.Dock="Top"
                                    Background="Transparent" ClipToBounds="False" Foreground="{DynamicResource MyDarkBlueSolidBrush}" FontFamily="Tahoma"
                                    Grid.Column="1" HorizontalAlignment="Left" Width="185" FontSize="14" FontStyle="Normal"
                                     >abc
                                </Label>
                                <Button  Name="closeButton" Margin="0,0,2,15" Click="closeButtonClick" Width="25"  Height="20"
                                TextBlock.FontWeight="Bold" Background="Transparent" BorderBrush="Transparent" Foreground="{DynamicResource MyDarkBlueSolidBrush}"
                                    HorizontalAlignment="Right" Grid.Column="1" BorderThickness="0" FontFamily="Webdings">
                                    r
                                    <!--<Image  Stretch="Fill" Source="/abc;component/graphics/close.png"></Image>-->
                                </Button>
                                <!--<Label Name="closeButton" Margin="0,0,2,15" MouseDown="closeButtonClick" Width="30"  Height="20" FontWeight="Bold" Foreground="{DynamicResource MyDarkBlueSolidBrush}" HorizontalAlignment="Right" Grid.Column="1" BorderThickness="0" FontSize="13">X
</Label>-->
                                <Button  Name="maximizeButton" Margin="0,0,26,15" Click="maximizeButtonClick" TextBlock.FontWeight="Bold"  Background="Transparent" BorderBrush="Transparent" Foreground="{DynamicResource MyDarkBlueSolidBrush}" Grid.Column="1" BorderThickness="0" Padding="0" Focusable="False" Width="25" Height="20" HorizontalAlignment="Right" VerticalAlignment="Center" Content="1" FontFamily="Webdings" FontWeight="Bold">
                                    <!--<Button.RenderTransform>
                                <RotateTransform Angle="271" CenterX="8" CenterY="17.5"></RotateTransform>
                            </Button.RenderTransform>-->
                                   <!--<Image  Stretch="UniformToFill" Source="/HID_okworkbench;component/graphics/max.jpg"></Image>-->
                               </Button>
                                <Button Name="minimizeButton" Margin="0,0,50,15" TextBlock.FontWeight="Bold" Foreground="{DynamicResource MyDarkBlueSolidBrush}"
                       Background="Transparent" BorderBrush="Transparent" BorderThickness="0"  Width="25" Height="20" FontWeight="Bold"
                               HorizontalAlignment="Right" Click="minimizeButtonClick" Grid.Column="1" FontSize="11" Focusable="False" Content="0" FontFamily="Webdings">
                                    <!--<Image Stretch="Fill" Source="graphics\maxi.jpg"></Image>-->

                                </Button>
                            </Grid>
                            <!-- TITLE BAR -->



                    </DockPanel>
                    <!-- Top PANEL -->

            </Grid>
        </Border>
    </Border>

</Window>
Posted
Updated 26-Sep-11 3:51am
v2
Comments
Simon Bang Terkildsen 26-Sep-11 9:54am    
Don't tell us what you want and dump alot of XAML. Tell us what you're trying to achieve and what problem(s) you have achieving it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900