Share via

How to customize the WPF window title bar so that its buttons are the same as Visual Stdio?

LoveC 61 Reputation points
2023-11-28T10:23:28.82+00:00

hi everyone!
When we customize the title bar, the button will be customized into the <Button> we set ourselves, but the effect it achieves is not the effect that comes with the system. For example, the customized title bar in Visual Stdio can be said It is consistent with the system and he also adds various functions to it.How should I achieve that effect? Thank you everyone! ! !

Developer technologies | Windows Presentation Foundation
Developer technologies | .NET | Other
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Answer accepted by question author

  1. Hui Liu-MSFT 48,711 Reputation points Microsoft External Staff
    2023-11-28T12:04:34.96+00:00

    Hi,@LoveC. Welcome to Microsoft Q&A Forum.

    The main window of your application has the maximize caption button available but does not show snap layouts, it may be because you've customized your caption buttons or title bar in a way that prevents it.

    Use the Windows App SDK windowing APIs and have the platform draw and implement the caption buttons for you. For Win32 apps, make sure you are responding appropriately to WM_NCHITTEST (with a return value of HTMAXBUTTON for the maximize/restore button).

    And link https://github.com/dotnet/wpf/issues/4825 is a discussion and solution about customizing the title bar snap layout. Among them, you could try the code sample to see if they help you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.