Cheruiyot Felix
Cheruiyot Felix

Reputation: 1597

WPF Popup like Windows Form

I would like to create a popup in wpf that behaves as windows form. I have manage to close the popup using [x] when it displays. I am stuck on how I can add functional minimize and maximize buttons feature. here is how i achieved the first step: close button: How to place close [x] in WPF popup

<Popup Name="myPopup" IsOpen="True">
    <StackPanel>
        <Label Background="AliceBlue" Foreground="Blue" HorizontalAlignment="Stretch" HorizontalContentAlignment="Right" MouseDown="mouse_DownHandled">
        x
        </Label>
        <Label Name="myLabel" Content="This is a popup!" Background="AliceBlue" Foreground="Blue"/>
    </StackPanel>
</Popup>

the mouse_DownHandled event closes the popup by setting isOpen=false

Any ideas?Thanks.

Upvotes: 0

Views: 2922

Answers (1)

gprasant
gprasant

Reputation: 16023

I see what you want. I think what you want is not a Popup Control but actually a WPF Window with a special style set in it. Use the WindowStyle property to achieve this.

Use

<Window Name="myPopup" WindowStyle="SingleBorderWindow">
    <StackPanel>
          <Label Name="myLabel" Content="This is a popup!" Background="AliceBlue" Foreground="Blue"/>
    </StackPanel>
</Window>

If you want to show this from the code, you can create create an instance of the view and call window.Show()

Your window should look like this enter image description here

Upvotes: 1

Related Questions