当前位置: 首页 > news >正文

一个 WPF 文档和工具窗口布局容器

一个 WPF 文档和工具窗口布局容器、用于排列文档 和工具窗口的方式与许多知名 IDE 类似,例如 Eclipse、Visual Studio、 PhotoShop 等等

AvalonDock 是一个 WPF 文档和工具窗口布局容器,用于排列文档 和工具窗口的方式与许多知名 IDE 类似,例如 Eclipse、Visual Studio、 PhotoShop 等等。

从源代码构建 AvalonDock (推荐)

此项目支持多目标框架(NetCore 3 和 .Net 4)。这意味着它需要 Visual Studio Community 2019 或更好的版本。

演示屏幕截图

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

开源地址

AvalonDock

实际简单使用查看下面代码

<Pagex:Class="FlightControlComputer.Views.Pages.RS422Page"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:avalonDock="https://github.com/Dirkster99/AvalonDock"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:local="clr-namespace:FlightControlComputer.Views.Pages"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"Title="RS422Page"d:DesignHeight="450"d:DesignWidth="800"UseLayoutRounding="True"mc:Ignorable="d"><DockingManagerx:Name="dockManager"Grid.Row="1"AllowMixedOrientation="True"AutoWindowSizeWhenOpened="True"IsVirtualizingAnchorable="True"IsVirtualizingDocument="True"><DockingManager.ContextMenu><ContextMenu><MenuItem Click="ShowSerialPage_Click" Header="一个数据区" /><MenuItem Click="ShowDataPage_Click" Header="二个数据区" /></ContextMenu></DockingManager.ContextMenu><DockingManager.Theme><Vs2013LightTheme /></DockingManager.Theme><DockingManager.DocumentHeaderTemplate><DataTemplate><StackPanel Orientation="Horizontal"><Image Margin="0,0,4,0" Source="{Binding IconSource}" /><TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis" /></StackPanel></DataTemplate></DockingManager.DocumentHeaderTemplate><LayoutRoot><!--  Only include the left side layout for docking  --><LayoutPanel Orientation="Horizontal"><!--<LayoutAnchorablePaneGroup DockWidth="50">--><LayoutAnchorablePane DockWidth="50"><LayoutAnchorableTitle="一个数据区"ContentId="toolWindow1"Hiding="OnToolWindow1Hiding"><StackPanel MinHeight="450"><!--  一个数据区窗口 的界面代码这里实现 --></StackPanel></LayoutAnchorable></LayoutAnchorablePane><LayoutAnchorablePane DockWidth="50"><LayoutAnchorable Title="二个数据区" ContentId="toolWindow2"><!--  另一个数据区窗口界面代码这里实现   --> </Grid></LayoutAnchorable></LayoutAnchorablePane><!--</LayoutAnchorablePaneGroup>--></LayoutPanel></LayoutRoot></DockingManager></Page>

后台代码

//关键代码#region TestBackground/// <summary>/// TestBackground Dependency Property/// </summary>public static readonly DependencyProperty TestBackgroundProperty =DependencyProperty.Register("TestBackground", typeof(Brush), typeof(RS422Page),new FrameworkPropertyMetadata((Brush)null));/// <summary>/// Gets or sets the TestBackground property.  This dependency property /// indicates a randomly changing brush (just for testing)./// </summary>public Brush TestBackground{get => (Brush)GetValue(TestBackgroundProperty);set => SetValue(TestBackgroundProperty, value);}#endregion#region FocusedElement/// <summary>/// FocusedElement Dependency Property/// </summary>public static readonly DependencyProperty FocusedElementProperty =DependencyProperty.Register("FocusedElement", typeof(string), typeof(RS422Page),new FrameworkPropertyMetadata((IInputElement)null));/// <summary>/// Gets or sets the FocusedElement property.  This dependency property /// indicates ..../// </summary>public string FocusedElement{get => (string)GetValue(FocusedElementProperty);set => SetValue(FocusedElementProperty, value);}#endregionprivate void OnLayoutRootPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e){var activeContent = ((LayoutRoot)sender).ActiveContent;if (e.PropertyName == "ActiveContent"){Debug.WriteLine(string.Format("ActiveContent-> {0}", activeContent));}}private void ShowSerialPage_Click(object sender, RoutedEventArgs e){var toolWindow1 = dockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == "toolWindow1");if (toolWindow1.IsHidden)toolWindow1.Show();else if (toolWindow1.IsVisible)toolWindow1.IsActive = true;elsetoolWindow1.AddToLayout(dockManager, AnchorableShowStrategy.Bottom | AnchorableShowStrategy.Most);}private void ShowDataPage_Click(object sender, RoutedEventArgs e){var toolWindow1 = dockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == "toolWindow2");if (toolWindow1.IsHidden)toolWindow1.Show();else if (toolWindow1.IsVisible)toolWindow1.IsActive = true;elsetoolWindow1.AddToLayout(dockManager, AnchorableShowStrategy.Bottom | AnchorableShowStrategy.Most);}
http://www.dtcms.com/a/340857.html

相关文章:

  • GitHub宕机应急指南:无缝协作方案
  • Eclipse 里Mybatis的xml的头部报错
  • 软考高级--系统架构设计师--案例分析真题解析
  • Java项目基本流程(五)
  • DeepSeek API 申请与 Node.js 对接指南
  • 服务器硬件电路设计之 SPI 问答(一):解密 SPI—— 从定义到核心特性
  • 服务器硬件电路设计之 SPI 问答(三):SPI 信号完整性守护与时钟频率的硬件设计羁绊
  • PCL+Spigot服务器+python进行MC编程2(使用RCON)---可以生成角色
  • 图论Day6学习心得
  • 源码编译部署 LAMP 架构详细步骤说明
  • 算法第五十二天:图论part03(第十一章)
  • 《算法导论》第 34 章 - NP 完全性
  • HTTP的协议
  • 【爬虫实战-IP代理的重要性二】 以Selenium为例
  • 在 Golang 中复用 HTTP 连接
  • JavaFx 动画-笔记
  • Docker操作速查表
  • MFQ测试分析与测试设计方法学习总结 (KYM)
  • 嵌入式开发学习———Linux环境下网络编程学习(四)
  • Java设计模式-命令模式
  • GitHub 热榜项目 - 日榜(2025-08-20)
  • Flask 之 Request 对象详解:全面掌握请求数据处理
  • 【NFTurbo】基于Redisson滑动窗口实现验证码发送限流
  • 如何在高并发下,保证共享数据的一致性
  • RabbitMQ的架构设计是什么样的
  • Unity 之如何使用Pico4u锚点功能实现一个世界锁GameRoot
  • 第二十七天:游戏组队问题
  • 【GPT入门】第49课 LlamaFacotory 训练千问
  • Mac电脑 Pixelmator Pro 专业图像处理【媲美PS】
  • UE5 InVideo插件打包报错