Implement a child window in WPF

Vivek Saurav picture Vivek Saurav · May 23, 2013 · Viewed 8.2k times · Source

Well its been little embarrassing ,but i am very new to wpf . and i want to implement a child window inside a parent window,which is movable and dragable inside the whole window. till now i have seen many blogs but all of them are very complicated and complex and its not easy to deploy my codes within it. here i have tried to implement in simple manner,

xaml:

<Window x:Class="Project_Explorer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpfx="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
        Title="Project Explorer">
 <Grid>
    <wpfx:ChildWindow Name="PopupChildWindow" Caption="Child Window" Height="200" IsModal="True" Margin="105,0,0,47" Width="306" HorizontalAlignment="Left" VerticalAlignment="Bottom" / >           
 </Grid>
</window>

please don't refer me to any post or website. just give a small demo xaml and xaml.cs file which implements child window.

Answer

George Birbilis picture George Birbilis · Jan 15, 2014

Try FloatingWindow/FloatingWindowHost - you can find the original version at CodeProject.com, or you can grab my updated version that also adds FloatingWindowHostZUI (with zooming and other extra stuff) and where I've mostly merged the WPF and Silverlight versions of the code (the original version had separate implementations).

See my version of that library at http://ClipFlair.codeplex.com (get the Source and checkout the Client/ZUI folder in the source, there are separate solutions available at FloatingWindow and FloatingWindowZUI folders there [the 2nd uses projects from the 1st one])

Note that these are not extending Window class, but you can make your code a UserControl and host it in a FloatingWindow, or make a FloatingWindow subclass and have your code in there directly.

You can try the FloatingWindow at http://ClipFlair.net, follow the Studio link there and then open the Tutorial activity. Play with Zoom slider from the FloatingWindowHost toolbar. Can also flip the Windows using the wrench button on their titlebar and set their properties at the back, like their individual Zoom (scale).