Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Pop up is appearing over other desktop windows, how to only appear on top of the WPF main window?

Tags:

wpf

popup

I have a WPF main window that has a grid and i have added a WPF pop up to ask the user for extra info when a button is clicked. But the problem is that when other desktop windows are moved over the pop up, the pop up covers the other desktop windows. How to fix this so the pop up is only top most of the WPF main window and not other desktop windows. The pop up is behaving like the task manager when set to always on top!

If you use the below code you will see that the pop up stays on top. So move any other desktop window over the pop up and the pop up will cover the other desktop application! Note that i do not want to use StaysOpen="False".

<Grid>
    <Popup Name="myPopup" Placement="Center" IsOpen="True">
        <StackPanel Background="Green" >
            <TextBox Width="200" Margin="0,0,10,0"/>
            <Button Name="closePopupBtn" Content="close" Width="100" />
        </StackPanel>
    </Popup>
</Grid>
like image 716
lymber Avatar asked Oct 21 '22 18:10

lymber


1 Answers

You have set the Owner property in the popup window. In your Popup Window,

this.owner = instanceOfParentWindow;

This is also similar to your question.

Popup always stays on top

Here they create a custom popup using user32.dll

like image 54
Anand Murali Avatar answered Oct 28 '22 21:10

Anand Murali