none
Floating WPF Usercontrol RRS feed

  • Question

  • Hi All,
    I have a application with three windows (WPF). One is main window and other two are the popup windows. I changed those two windows to Usercontrol and implemented it inside the main window. Now the Usercontrol is bounded along with the layout of the main window, but I want it to be floating (independent of the parent layout) just like popup. How to change its behaviour?


    Tuesday, April 15, 2008 2:51 AM

Answers

  •  Venkatesh Mookkan wrote:

    I have a application with three windows (WPF). One is main window and other two are the popup windows. I changed those two windows to Usercontrol and implemented it inside the main window. Now the Usercontrol is bounded along with the layout of the main window, but I want it to be floating (independent of the parent layout) just like popup. How to change its behaviour?


    Only Popup (aka Seperate hwnd) can enable this type of scenario, if you need Popup specific behaviour, please use Popup, if not, use other controls.

    Thanks
    Thursday, April 17, 2008 2:44 AM
  • Yes it can, simply by doing so:
    <Popup>
       <UserControl/>
    </Popup>

    Hope this helps
    Thursday, April 17, 2008 4:49 AM

All replies

  • You are right, the popup is now subject to the containing layout.  There is no built in functionality that I know of that does this, but there are several examples online that show how to create a draggable element.  Maybe Josh's Draggable Canvas would give you a good start.  There are a few WPF MDI examples out there too that might fill the bill for you.

     

    -Jer

    Tuesday, April 15, 2008 3:02 AM
  • Hey Jeremiah,
    Thanks for replying. But the example you gave it not answer to my question. Mr. Josh has used Canvas to do all his magics. But my application is not using canvas. Its using StackPanels and Grids.

    And also I am not concern about the drag drop of the User Control right. I need to make User control to be floating over like a Popup. Is there any behaviour property that help me to do this?
    Tuesday, April 15, 2008 3:11 AM
  •  Venkatesh Mookkan wrote:

    I have a application with three windows (WPF). One is main window and other two are the popup windows. I changed those two windows to Usercontrol and implemented it inside the main window. Now the Usercontrol is bounded along with the layout of the main window, but I want it to be floating (independent of the parent layout) just like popup. How to change its behaviour?


    Only Popup (aka Seperate hwnd) can enable this type of scenario, if you need Popup specific behaviour, please use Popup, if not, use other controls.

    Thanks
    Thursday, April 17, 2008 2:44 AM
  • Thanks for replying Marco.

    Does Popup allow me to have my Usercontrol inside? This application is developed using WPF-CAB guideline. Most of the screens are developed as Usercontrols. If I could float it on the main window like Popup (Even I would handle the modal /drag-drop property later on) that would be great. Tell me if Popup can hold a user control...
    Thursday, April 17, 2008 3:11 AM
  • Yes it can, simply by doing so:
    <Popup>
       <UserControl/>
    </Popup>

    Hope this helps
    Thursday, April 17, 2008 4:49 AM
  • Marco,
    If Popup is the only way to solve my problem, then I have live with it. But I am still searching for better solution.

    I marked your suggestion as answer since the other users who are searching solution for the same issue can use it.

    Thanks.
    Friday, April 18, 2008 3:39 AM
  • Are you looking to float some controls on top of other controls on the main window? Something like:

     

    Code Snippet

    <Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>

        <Grid>
            <StackPanel>
                <Button Content="Test" Height="100" />
                <Button Content="Test" Height="100" />
                <Button Content="Test" Height="100" />
                <Button Content="Test" Height="100" />
            </StackPanel>

     

            <Border Background="Red" Width="50" Height="50"

                Margin="80" HorizontalAlignment="Left"

                VerticalAlignment="Top">
                    <TextBlock Text="Floating" />
            </Border>
        </Grid>
    </Page>

     

     

    Friday, April 18, 2008 6:06 AM
  • Hi:

    I've a problem with Popup, when I move my main window or when minimize it, the Popup remains in a fixed position, absolute.

    Any property that sets Popup position relative and locked to parent top-left position?

    Thanks for help.

    vakilzadeh at gmail dot com
    Monday, May 5, 2008 7:43 AM
  • Use the StaysOpen property: 

    StaysOpen = false;

    Thursday, July 24, 2008 2:12 PM
  • AVEbrahimi

    sir i to have same problem if we put stays open=false
    the popup gone to closed
    now actually we need is popup will minimize for a button click when ever we press
    main window remains with having same data it will come from toolbar
    can u please help me out from this problem

    Thanks in advance
    Wednesday, September 9, 2009 5:14 AM
  • A day late, but for future reference, you have to close the popups in the main windows minimize event or trigger.
    Friday, September 10, 2010 5:49 PM