How do I implement a chromeless window with WPF?

前端 未结 3 1466
难免孤独
难免孤独 2020-12-15 17:43

I want to show a chromeless modal window with a close button in the upper right corner. Is this possible?

相关标签:
3条回答
  • 2020-12-15 18:13

    Check out this blog post on kirupa.

    alt text

    0 讨论(0)
  • 2020-12-15 18:16
    <Window x:Class="WpfApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300" WindowStyle="None" ResizeMode="NoResize">
        <Button HorizontalAlignment="Right" Name="button1" VerticalAlignment="Top" >Close</Button>
    </Window>
    
    0 讨论(0)
  • 2020-12-15 18:36

    You'll pretty much have to roll your own Close button, but you can hide the window chrome completely using the WindowStyle attribute, like this:

    <Window WindowStyle="None">
    

    That will still have a resize border. If you want to make the window non-resizable then add ResizeMode="NoResize" to the declaration.

    0 讨论(0)
提交回复
热议问题