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 6372363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:13:43+00:00 2026-05-25T01:13:43+00:00

I am using the WPF toolkit and the WPF toolkit extended and notice that

  • 0

I am using the WPF toolkit and the WPF toolkit extended and notice that when I display a message box via:

MessageBox.Show("...");

I get the following…

enter image description here

I would like to make my main application window use this styling as well. Is there a way to do it?

EDIT: I’ve tried WindowStyle=”ToolWindow” and it doesn’t work.

Edit: In response to the answer below, please see picture below:

enter image description here

Also, I would like it to have a maximize and minimize button but with the same style as the button for close.

Thank you!

  • 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-25T01:13:43+00:00Added an answer on May 25, 2026 at 1:13 am

    I want to add a disclaimer here that I threw this together pretty quickly out of curiosity, more than anything. I haven’t tested this much, other than dropping a few controls on there and running it. It works, but is shouldn’t be considered fully complete. I also think there are probably better ways to do this, but I figured this would at least give you a good starting place.

    Add a new ResourceDictionary to your project, and add the following XAML:

    <ResourceDictionary
      x:Class="CustomWindow.BaseResource"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <Style x:Key="WindowStyle" TargetType="{x:Type Window}">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="WindowStyle" Value="None" />
        <Setter Property="ResizeMode" Value="NoResize" />
        <Setter Property="Background" Value="White" />
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}">
              <Border
                x:Name="WindowBorder"
                BorderBrush="Black"
                BorderThickness="1">
                <Border.Background>
                  <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Offset="0" Color="White" />
                    <GradientStop Offset="1" Color="#FFDADADA" />
                  </LinearGradientBrush>
                </Border.Background>
                <Grid
                  Width="{TemplateBinding Width}"
                  Height="{TemplateBinding Height}"
                  MinWidth="{TemplateBinding MinWidth}"
                  MinHeight="{TemplateBinding MinHeight}"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top"
                  Cursor="Arrow">
                  <Grid.RowDefinitions>
                    <RowDefinition Height="25" />
                    <RowDefinition Height="*" />
                  </Grid.RowDefinitions>
                  <TextBlock
                    Width="500"
                    Height="23"
                    Margin="11,2,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top"
                    Text="{TemplateBinding Title}" />
                  <Rectangle
                    x:Name="TitleBar"
                    Fill="Transparent"
                    MouseDown="TitleBar_MouseDown" />
                  <Rectangle
                    Grid.RowSpan="2"
                    Width="10"
                    HorizontalAlignment="Left"
                    Cursor="SizeWE"
                    Fill="Transparent"
                    MouseDown="Border_MouseDown"
                    Tag="Left" />
                  <Rectangle
                    Grid.RowSpan="2"
                    Width="10"
                    HorizontalAlignment="Right"
                    Cursor="SizeWE"
                    Fill="Transparent"
                    MouseDown="Border_MouseDown"
                    Tag="Right" />
                  <Rectangle
                    Height="5"
                    VerticalAlignment="Top"
                    Cursor="SizeNS"
                    Fill="Transparent"
                    MouseDown="Border_MouseDown"
                    Tag="Top" />
                  <Rectangle
                    Grid.Row="1"
                    Height="10"
                    VerticalAlignment="Bottom"
                    Cursor="SizeNS"
                    Fill="Transparent"
                    MouseDown="Border_MouseDown"
                    Tag="Bottom" />
                  <StackPanel
                    Margin="10,0"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Top"
                    Orientation="Horizontal">
                    <Button
                      x:Name="MinimizeButton"
                      Width="43"
                      Height="17"
                      Click="MinimizeButton_Click"
                      IsTabStop="False">
                      min
                    </Button>
                    <Button
                      x:Name="MaximizeButton"
                      Width="43"
                      Height="17"
                      Margin="5,0"
                      Click="MaximizeButton_Click"
                      IsTabStop="False">
                      max
                    </Button>
                    <Button
                      x:Name="CloseButton"
                      Width="43"
                      Height="17"
                      Click="CloseButton_Click"
                      IsTabStop="False">
                      <Path
                        Width="12"
                        Height="10"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Data="M0.5,0.5L4.5178828,0.5 6.0620003,3.125 7.4936447,
                          0.5 11.5,0.5 11.5,1.5476431 8.7425003,6.1201854 11.5,
                          10.359666 11.5,11.5 7.4941902,11.5 6.0620003,8.8740005 
                          4.5172949,11.5 0.5,11.5 0.5,10.43379 3.3059995,
                          6.1201582 0.5,1.4676378 0.5,0.5z"
                        Fill="#E4FFFFFF"
                        Stretch="Fill"
                        Stroke="#FF535666" />
                    </Button>
                  </StackPanel>
                  <Border
                    Grid.Row="1"
                    Margin="10,0,10,10"
                    BorderBrush="Black"
                    BorderThickness="1">
                    <Grid>
                      <Rectangle Fill="White" />
                      <ContentPresenter Content="{TemplateBinding Content}" />
                    </Grid>
                  </Border>
                </Grid>
              </Border>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
    </ResourceDictionary>
    

    For illustrative purposes, let’s say we named the ResourceDictionary, BaseResource.xaml.

    Next add a new Class to the same directory where you added the resource, and name the file BaseResource.xaml.cs, substituting the actual name of your XAML file.

    Go back to BaseResource.xaml and change the x:Class="CustomWindow.BaseResource" property to the full type name of the ResourceDictionary. If changed correctly, Visual Studio should complain that there is a duplicate definition in BaseResource.xaml.cs. Fix that by adding the partial keyword modifier to the class in the .cs file.

    Finally, add the following code to the code file:

    using System;
    using System.Runtime.InteropServices;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Interop;
    using System.Windows.Media;
    
    namespace CustomWindow
    {
        public partial class BaseResource
        {
            private const uint WM_SYSCOMMAND = 0x112;
    
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            private static extern IntPtr 
                SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
    
            private void CloseButton_Click(object sender, RoutedEventArgs e)
            {
                e.Handled = true;
                Window.GetWindow((DependencyObject) sender).Close();
            }
    
            private void MinimizeButton_Click(object sender, RoutedEventArgs e)
            {
                e.Handled = true;
                Window.GetWindow((DependencyObject) sender).WindowState = WindowState.Minimized;
            }
    
            private void MaximizeButton_Click(object sender, RoutedEventArgs e)
            {
                e.Handled = true;
                var window = Window.GetWindow((DependencyObject) sender);
                window.WindowState = 
                  (window.WindowState == WindowState.Maximized) ? WindowState.Normal : WindowState.Maximized;
            }
    
            private void TitleBar_MouseDown(object sender, MouseButtonEventArgs e)
            {
                e.Handled = true;
                Window.GetWindow((DependencyObject) sender).DragMove();
            }
    
            private void Border_MouseDown(object sender, MouseButtonEventArgs e)
            {
                e.Handled = true;
                var direction = (Direction)Enum.Parse(typeof(Direction), ((FrameworkElement)sender).Tag.ToString());
                ResizeWindow(PresentationSource.FromVisual((Visual)sender) as HwndSource, direction);
            }
    
            private void ResizeWindow(HwndSource hwndSource, Direction direction)
            {
                SendMessage(hwndSource.Handle, WM_SYSCOMMAND, (int)(61440 + direction), 0);
            }
    
            private enum Direction
            {
                Left = 1,
                Right = 2,
                Top = 3,
                TopLeft = 4,
                TopRight = 5,
                Bottom = 6,
                BottomLeft = 7,
                BottomRight = 8,
            }
        }
    }
    

    Next add the ResourceDictionary to global Application resources. Again, substituting BaseResource.xaml with the name of your file, if it is different.

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/BaseResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
    

    Add the style to the target Window.

    <Window
      ...
      Style="{StaticResource WindowStyle}">
    

    A few things…

    The designer messes with the style when there is no content. It is probably because of where I placed the TemplateBinding for Height and Width, but it looks fine at runtime, so I didn’t mess with it further. I also didn’t implement the resize grip for the corners, but it is easy enough to add to the template.

    Finally, I didn’t draw icons for the Minimize and Maximize buttons. I suck at creating Paths in Blend.

    Hope it helps.

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

Sidebar

Related Questions

I have a richtextbox (WPF extended toolkit) that I am using in my WPF
I am using WPF toolkit provided DataGrid control to display product list along with
I am using the WPF toolkit, and am trying to render a graph that
I'm using the WPF Toolkit's DataGrid to display a set of search results. As
I am using the WPF toolkit datagrid to display some data and want to
I am using the WPF Calendar that is part of the WPF Toolkit. I
I have a WPF application and am using the WPF toolkit autocomplete box in
I'm using the WPF Extended Toolkit ( http://wpftoolkit.codeplex.com/ ). It has a nice NumericUpDown
I'm using the 'Extended WPF Toolkit' ( http://wpftoolkit.codeplex.com/ ), and for my own purposes
I am using the Extended WPF Toolkit in one of my applications, and I

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.