简体   繁体   English

如何在WPF(C#)中创建可停靠窗口?

[英]How can I create a dockable window in WPF (C#)?

Let's say you have a view (userControl) with its own XAML code, and another window (window) also with its own XAML code. 假设您有一个带有自己的XAML代码的视图(userControl),另一个窗口(窗口)也有自己的XAML代码。 Is there any way to be able to dock this window into the view (the view will rearrange the UI to accomodate the docked window), but also get the window out of the view if you want to move the window around? 有没有办法可以将此窗口停靠在视图中(视图将重新排列UI以容纳停靠的窗口),但如果要移动窗口,还可以将窗口移出视图?

Check out AvalonDock project. 查看AvalonDock项目。

AvalonDock is a docking windows control for WPF that lets you create customizable layouts using a full featured window docking system similar to what is found in many popular integrated development environements (IDEs) such as Visual Studio. AvalonDock是WPF的停靠窗口控件,可让您使用类似于许多流行的集成开发环境(IDE)(如Visual Studio)中的全功能窗口对接系统来创建可自定义的布局。 It includes themes and samples to get you started. 它包括主题和示例,以帮助您入门。

Example of usage: 用法示例:

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonDock="http://avalondock.codeplex.com"
        Title="MainWindow" Height="434" Width="684">
    <Grid>
        <avalonDock:DockingManager x:Name="dockingManager">
            <avalonDock:LayoutRoot>
                <avalonDock:LayoutPanel Orientation="Horizontal">
                    <avalonDock:LayoutDocumentPane/>
                    <avalonDock:LayoutAnchorablePane DockWidth="150">
                        <avalonDock:LayoutAnchorable Title="Sample Tool Pane">
                            <TextBox/>
                        </avalonDock:LayoutAnchorable>
                    </avalonDock:LayoutAnchorablePane>
                </avalonDock:LayoutPanel>
                <avalonDock:LayoutRoot.LeftSide>
                    <avalonDock:LayoutAnchorSide>
                        <avalonDock:LayoutAnchorGroup>
                            <avalonDock:LayoutAnchorable Title="Autohidden Content">
                                <TextBox/>
                            </avalonDock:LayoutAnchorable>
                        </avalonDock:LayoutAnchorGroup>
                    </avalonDock:LayoutAnchorSide>
                </avalonDock:LayoutRoot.LeftSide>
            </avalonDock:LayoutRoot>
        </avalonDock:DockingManager>
    </Grid>
</Window>

Documentation you can find here . 您可以在此处找到文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以c#.net可停靠形式将MinimumSize与AutoScrollMinSize结合使用? - How can I combine MinimumSize with AutoScrollMinSize in c# .net dockable forms? C#WPF如何创建可以创建特定窗口的通用方法 - C# WPF How to create a generic method that can create a specific Window 如何在 C# 窗口应用程序中以编程方式创建按钮? - How can I create a button programmatically in C# window app? 如何仅使用c#代码在图像对象上创建旋转动画(在WPF窗口内) - How do I create a rotate animation on an image object using c# code only (inside a WPF window) 创建非活动C#WPF窗口的缩略图 - Create a thumbnail of an inactive C# WPF Window 如何在WPF / C#中检测鼠标是否在我的窗口范围内移动? - How can i detect if the mouse is moving both within and out of the bounds of my window in WPF/C#? 如何首先打开 window 而不是 WPF 中的 MainWindow(C#) - How can I open a window first, instead of a MainWindow in WPF (C#) 如何在 revit api c# 中以编程方式注册可停靠面板 - How to register dockable panel programmatically in revit api c# 我如何在 wpf 窗口 c# 中显示数据表? - how do i display a DataTable in a wpf window c#? 如何基于现有窗口创建一个新的C#窗口? - How can I create a new C# Window based on my existing Window?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM