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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:31:47+00:00 2026-05-31T03:31:47+00:00

I have restyled a WPF window, everything works really well. However, I now need

  • 0

I have restyled a WPF window, everything works really well. However, I now need to display a pop-up menu when someone clicks on the title bar. I don’t don’t understand how I can do this as the title down click is handled by a mouse down in one of borders in the style, and this is generic style that I am applying to several windows?

The window style looks like this:

<Style x:Key="MYWindow" TargetType="{x:Type Window}">
    <Setter Property="ResizeMode" Value="NoResize" />
    <Setter Property="WindowStyle" Value="None" />
    <Setter Property="Background" Value="{StaticResource BGBrush}" />
    <Setter Property="Foreground" Value="{StaticResource FGBrush}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="26"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="26"/>
                        <ColumnDefinition Width="26"/>
                        <ColumnDefinition Width="26"/>
                    </Grid.ColumnDefinitions>

                    <Border Background="{TemplateBinding Background}" BorderThickness="1" BorderBrush="{x:Null}" CornerRadius="5,5,5,5" BitmapEffect="{StaticResource DropShadow}" Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="4"/>

                    <ContentPresenter Margin="2" ClipToBounds="True" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4"/>

                    <Border Background="{StaticResource GreyGradientBrush}" BorderThickness="1" BorderBrush="{x:Null}" CornerRadius="5,5,0,0" BitmapEffect="{StaticResource WindowTitleShadow}" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" MouseDown="HandleTitleBarMouseDown"/>

Currently HandleTitleBarMouseDown handles the dragging of the window as follows:

  partial class MYStyles
  {

    public void HandleTitleBarMouseDown(object sender, MouseButtonEventArgs e)
    {
      Window window = GetWindow(sender);

      window.DragMove();
    }
}

I re-use the style as follows:

<Window x:Class="TestWPF.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"        
    xmlns:local="clr-namespace:TestWPF"
    Style="{DynamicResource MYWindow}" Title="Test MY Window" Height="599" Width="891" SnapsToDevicePixels="False" WindowStyle="None" Padding="0" MouseDown="">

I need to somehow have an event raised in the Window1 class but have no idea how to achieve this?

  • 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-31T03:31:49+00:00Added an answer on May 31, 2026 at 3:31 am

    You can use global event hooking.

    Put this line in your app.xaml.cs or whatever class is called when you start the application:

    EventManager.RegisterClassHandler(typeof(Window), Window.PreviewMouseUpEvent, new MouseButtonEventHandler(OnWindowPreviewMouseUp));
    

    And declare the OnWindowPreviewMouseUp event handler:

    void OnWindowPreviewMouseUp(object sender, MouseButtonEventArgs e)
            {
                //do your implementation
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a label in WPF which I want to restyle so it has
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
have been trying couple of hours now to make my iphone app universal. The
Each item in a WPF ListBox control seems to have a bit of left
I have restyled the DataGridRowGroupHeader on my datagrid because I want to change the
I have seen this post: WPF ComboBox: background color when disabled and some others...
Have a rails app that is supposed to display a list of products/managers. After
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could

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.