在 WPF 中实现子窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16706484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Implement a child window in WPF
提问by Vivek Saurav
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,
嗯,这有点尴尬,但我对 wpf 很陌生。我想在父窗口内实现一个子窗口,它在整个窗口内是可移动和可拖动的。到目前为止,我已经看过很多博客,但它们都非常复杂,而且在其中部署我的代码并不容易。在这里,我尝试以简单的方式实现,
xaml:
xml:
<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.
请不要向我推荐任何帖子或网站。只需给出一个实现子窗口的小演示 xaml 和 xaml.cs 文件。
采纳答案by George Birbilis
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).
尝试 FloatingWindow/FloatingWindowHost - 您可以在 CodeProject.com 上找到原始版本,或者您可以获取我的更新版本,该版本还添加了 FloatingWindowHostZUI(带有缩放和其他额外内容),并且我主要合并了 WPF 和 Silverlight 版本的代码(原始版本有单独的实现)。
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])
在http://ClipFlair.codeplex.com 上查看我的该库版本(获取源代码并检查源代码中的 Client/ZUI 文件夹,在 FloatingWindow 和 FloatingWindowZUI 文件夹中有单独的解决方案可用[第二个使用项目从第一个一])
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.
请注意,这些不是扩展 Window 类,但您可以将代码设置为 UserControl 并将其托管在 FloatingWindow 中,或者创建一个 FloatingWindow 子类并将代码直接放在那里。
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).
您可以在http://ClipFlair.net尝试 FloatingWindow ,点击此处的 Studio 链接,然后打开教程活动。从 FloatingWindowHost 工具栏中使用缩放滑块。还可以使用标题栏上的扳手按钮翻转 Windows,并在后面设置它们的属性,例如它们的单独缩放(比例)。

