Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3336900
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:11:26+00:00 2026-05-18T00:11:26+00:00

I am going to develop my own window where I’ll have my own Caption

  • 0
 I am going to develop my own window where I'll have my own Caption Buttons 

(Minimize, Maximize, Restore and Close) and all the properties related to these
buttons and can add any control at the title position of the window.

Suggest me the way how I’ll proceed for it please……

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:11:27+00:00Added an answer on May 18, 2026 at 12:11 am

    My suggestion is NOT to do it. This is not needed in WPF.

    Simply change the Window template and you’ll get what you ask.

    Edit:
    Here is an example.

    <ResourceDictionary 
        x:Class="MyNamespace.StyleWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <LinearGradientBrush x:Key="BackgroundBrush" StartPoint="0.5,1" EndPoint="0.5,0">
            <GradientStop Color="#FFEBECEE" Offset="1"/>
            <GradientStop Color="#FFC2C7CD" Offset="0"/>
        </LinearGradientBrush>
        <Style TargetType="{x:Type Border}" x:Key = "MainBorder">
            <Setter Property="Background" Value="#CACDD6" />
            <Setter Property="BorderBrush" Value="#395984" />
            <Setter Property="BorderThickness" Value="0.25" />
            <!--<Setter Property="CornerRadius" Value="10"/>-->
            <Setter Property="Padding" Value="0" />
        </Style>
        <Style TargetType="{x:Type Button}" x:Key="TitleWindowButton">
            <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Height" Value="25" />
            <Setter Property="Width" Value="25" />
        </Style>
        <Style x:Key="WindowStyle" TargetType="{x:Type Window}">
            <Setter Property="AllowsTransparency" Value="False" />
            <Setter Property="WindowStyle" Value="None" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="ResizeMode" Value="CanResizeWithGrip" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Window}">
                        <Grid>
    
                            <Border Width="Auto" Height="Auto" Style="{StaticResource MainBorder}" >
                                <DockPanel   
                      HorizontalAlignment="Stretch" Background="Transparent" VerticalAlignment="Stretch">
                                    <Border Height="28" Name="border2" BorderThickness="0,0,0,1" BorderBrush="DarkGray" Background="{StaticResource BackgroundBrush}"
                        MouseLeftButtonDown="OnMouseLeftButtonDown" DockPanel.Dock="Top">
                                        <Grid Name="grid1">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="22" />
                                                <ColumnDefinition Width="176*" />
                                                <ColumnDefinition Width="75" />
                                            </Grid.ColumnDefinitions>
    
                                            <DockPanel HorizontalAlignment="Right" Grid.Column="2">
                                                <Button Style="{StaticResource TitleWindowButton}" Name="m_btnMinimine" Click="m_btnMinimine_Click">
                                                    <Image Source="Images/min.png"></Image>
                                                </Button>
                                                <Button Style="{StaticResource TitleWindowButton}" Name="m_btnMaximine" Click="m_btnMaximine_Click">
                                                    <Image Source="Images/max.png"></Image>
                                                </Button>
                                                <Button Style="{StaticResource TitleWindowButton}" Name="m_btnClose" Click="m_btnClose_Click">
                                                    <Image Source="Images/close.png"></Image>
                                                </Button>
                                            </DockPanel>
                                            <Image Source="{Binding Path=Icon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                                            <Label Grid.Column="1">
                                                <ContentPresenter ContentSource="Title" RecognizesAccessKey="True" />
                                            </Label>
                                        </Grid>
                                    </Border>
    
                                    <AdornerDecorator>
                                        <ContentPresenter />
                                    </AdornerDecorator>
                                </DockPanel>
    
                            </Border>
    
                            <Line MouseDown="OnSizeNorth" Name="lnSizeNorth" Stroke="Transparent"   
                  Cursor="SizeNS" X1="10" X2="{TemplateBinding ActualWidth}"
                  Y1="1" Y2="1" StrokeThickness="2"  />
    
                            <Line MouseDown="OnSizeSouth" Name="lnSizeSouth" Stroke="Transparent" VerticalAlignment="Bottom" 
                       Cursor="SizeNS" X1="1" X2="{TemplateBinding ActualWidth}" 
                      Y1="{TemplateBinding ActualHeight}" Y2="{TemplateBinding ActualHeight}" StrokeThickness="2" />
                            <Line MouseDown="OnSizeWest" Name="lnSizeWest" Stroke="Transparent"
                      Cursor="SizeWE" X1="1" X2="1" Y1="1" Y2="{TemplateBinding ActualHeight}"  StrokeThickness="2" />
                            <Line MouseDown="OnSizeEast" Name="lnSizeEast" Stroke="Transparent" HorizontalAlignment="Right" 
                      Cursor="SizeWE" X1="{TemplateBinding ActualWidth}" 
                  X2="{TemplateBinding ActualWidth}" Y1="1" Y2="{TemplateBinding ActualHeight}"  StrokeThickness="2" />
    
                            <Rectangle MouseDown="OnSizeNorthWest" Name="rectSizeNorthWest" Cursor="SizeNWSE" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Top" HorizontalAlignment="Left" />
                            <Rectangle MouseDown="OnSizeNorthEast" Name="rectSizeNorthEast" Cursor="SizeNESW" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Top" HorizontalAlignment="Right" />
                            <Rectangle MouseDown="OnSizeSouthWest" Name="rectSizeSouthWest" Cursor="SizeNESW" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
                            <Rectangle MouseDown="OnSizeSouthEast" Name="rectSizeSouthEast" Cursor="SizeNWSE" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
    
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
    
            </Setter>
        </Style>
    </ResourceDictionary>
    

    You need the 3 images for the min / max / normal / close buttons (referenced in the images as Images/min.png, Images/max.png, Images/normal.png, Images/close.png).

    Compiling the resource dictionary gives a MyNamespace.StyleWindow class which you can complement with event handlers:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows;
    using System.Runtime.InteropServices;
    using System.Windows.Interop;
    using System.Windows.Input;
    using System.Windows.Media.Imaging;
    using System.Windows.Controls;
    
    namespace MyNamespace {
        public partial class StyleWindow {
            private void m_btnClose_Click(object sender, RoutedEventArgs e) {
                Window window = ((FrameworkElement)sender).TemplatedParent as Window;
                if (window != null)
                {
                    window.Close();
                }
            }
    
            private void m_btnMaximine_Click(object sender, RoutedEventArgs e) {
                Window window = ((FrameworkElement)sender).TemplatedParent as Window;
                if (window != null)
                {
                    BitmapImage bitmap = new BitmapImage();
    
                    if (window.WindowState == WindowState.Maximized) {
                        window.WindowState = WindowState.Normal;
                        bitmap.BeginInit();
                        bitmap.UriSource = new Uri(@"Images/max.PNG", UriKind.Relative);
                        bitmap.EndInit();
                        ((sender as Button).Content as Image).Source = bitmap;
                    } else {
                        window.WindowState = WindowState.Maximized;
                        bitmap.BeginInit();
                        bitmap.UriSource = new Uri(@"Images/normal.PNG", UriKind.Relative);
                        bitmap.EndInit();
                        ((sender as Button).Content as Image).Source = bitmap;
                    }
                }
            }
    
            private void m_btnMinimine_Click(object sender, RoutedEventArgs e) {
                Window window = ((FrameworkElement)sender).TemplatedParent as Window;
                if (window != null)
                {
                    window.WindowState = WindowState.Minimized;
                }
            }
    
            private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                Window window = ((FrameworkElement)sender).TemplatedParent as Window;
                if (window != null)
                {
                    window.DragMove();
                }
    
            }
    
            #region sizing event handlers
    
            void OnSizeSouth(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.South);
                }
            }
    
            void OnSizeNorth(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.North);
                }
            }
    
            void OnSizeEast(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.East);
                }
            }
    
            void OnSizeWest(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.West);
                }
            }
    
            void OnSizeNorthWest(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.NorthWest);
                }
            }
    
            void OnSizeNorthEast(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.NorthEast);
                }
            }
    
            void OnSizeSouthEast(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.SouthEast);
                }
            }
    
            void OnSizeSouthWest(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Window wnd = ((FrameworkElement) sender).TemplatedParent as Window;
                if (wnd != null) {
                    WindowInteropHelper helper = new WindowInteropHelper(wnd);
                    DragSize(helper.Handle, SizingAction.SouthWest);
                }
            }
    
    
            #endregion
    
            #region P/Invoke and helper method
    
            const int WM_SYSCOMMAND = 0x112;
            const int SC_SIZE = 0xF000;
    
    
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
    
            void DragSize(IntPtr handle, SizingAction sizingAction) {
                if (System.Windows.Input.Mouse.LeftButton == System.Windows.Input.MouseButtonState.Pressed) {
                    SendMessage(handle, WM_SYSCOMMAND, (IntPtr) (SC_SIZE + sizingAction), IntPtr.Zero);
                    SendMessage(handle, 514, IntPtr.Zero, IntPtr.Zero);
                }
            }
    
            #endregion
    
            #region helper enum
    
            public enum SizingAction {
                North = 3,
                South = 6,
                East = 2,
                West = 1,
                NorthEast = 5,
                NorthWest = 4,
                SouthEast = 8,
                SouthWest = 7
            }
        }
            #endregion
    }
    

    This resource should be globally available. You can reference it in XAML like this:

    …

    In my project, the designer tended to choke on this reference (maybe because it was a WinForms project with a main body made up of WPF elements). Because of this, we had to set the style programmatically, in the code-behind, in the window constructor:

    Style = (Style) FindResource(Constants.DEFAULT_WINDOW_STYLE);

    with a constant declaration with the value “WindowStyle”.

    Here is the result (I apologize for the empty content, but it is confidential):
    alt text

    I did not say it was pretty…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If we are going to develop a community website for non geeks, is it
I am going to develop real time application which will receive stock market data
I am going to develop ICQ client and I just wonder where can I
I am going to develop an application which will process online data (comming through
I am asking about that as I am going to develop a client side
If I develop a .Net application that's going to run on WinXP and Vista,
At our company we are going to develop more for the Windows platform than
One thing I've always wanted to do is develop my very own operating system
After years in embedded programming, I have to develop a Windows app. I dug
Recently we are going to develop some products on mobile phone (specially for 3g).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.