wpf devexpress 添加GanttControl到项目

这个教程示范如何添加GanttControl 到你的项目使用内置GanttControl数据类。

要求

添加 Devexpress.Wpf.Gantt Nuget包到你的项目使用GanttControl.

数据模型

GanttControl携带和内置数据对象,可以使用创建视图模型:

GanttTask

呈现甘特图任务

GanttPredecessorLink

呈现任务关系

GanttTask类曝光如下属性:

属性描述
Id指定任务id
ParentId指定任务父id
StartDate指定任务开始日期
FinishDate指定任务结束日期
Progress指定任务进程
Name指定任务名称和标题
BaselineStartDate指定任务基线开始日期
BaselineFinishDate指定任务基线完成日期
PredecessorLinks提供访问任务记录集合

Id和ParentId属性允许组织任务等级体系在空白数据集合

GanttPredecessorLink提供如下属性

属性描述
PredecessorTask Id指定访问记录Id
LinkType指定任务关系类型(完成ToStart,FinishToFinish,等等)
Lag指定依赖时间lag

添加视图模型

创建视图模型类暴露Tasks属性ObservableCollection<GanttTask>类型

代码例子如下示范了视图模型

using DevExpress.Mvvm.Gantt;
using System;
using System.Collections.ObjectModel;namespace GanttControlDemoApp {public class ProjectTaskViewModel {public ObservableCollection<GanttTask> Tasks { get; set; }public ProjectTaskViewModel() {Tasks = new ObservableCollection<GanttTask> {new GanttTask() {Id = 0,Name = "Add a new feature",StartDate = DateTime.Now.AddDays(-1),FinishDate = DateTime.Now.AddDays(6)},new GanttTask() {Id =1, ParentId = 0,Name = "Write the code",StartDate = DateTime.Now.AddDays(-1),FinishDate = DateTime.Now.AddDays(2)},new GanttTask() {Id = 2,ParentId = 0,Name = "Write the docs",StartDate = DateTime.Now.AddDays(2),FinishDate = DateTime.Now.AddDays(5)},new GanttTask() {Id = 3,ParentId = 0,Name = "Test the new feature",StartDate = DateTime.Now.AddDays(2),FinishDate = DateTime.Now.AddDays(5)},new GanttTask() {Id = 4,ParentId = 0,Name = "Release the new feature",StartDate = DateTime.Now.AddDays(5),FinishDate = DateTime.Now.AddDays(6),}};}}
}

添加Gantt Control到视图

添加GanttControl到项目

打开vs工具箱,找到DX.18.2:Data & Analytics 页面,拖动GanttControl 工具箱内容,拖动到window控件

传递视图模型到视图DataContext属性,绑定GanttControl的ItemsSource属性到视图模型Task属性

<Windowxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:GanttControlDemoApp"xmlns:dxgn="http://schemas.devexpress.com/winfx/2008/xaml/gantt" x:Class="GanttControlDemoApp.MainWindow"><Window.DataContext><local:ProjectTaskViewModel /></Window.DataContext><Grid><dxgn:GanttControl ItemsSource="{Binding Tasks}" /></Grid>
</Window> 

图片如下演示了结果

GanttControl显示统计任务和折叠子任务。显示数据行和任务属性和显示所有任务

添加任务行

使用控件的GanttControl.Columns属性添加行

甘特图行显示通过GanttColumn类。绑定行到任何任务标准属性使用BindTo 属性。像如下代码

<dxgn:GanttControl ItemsSource="{Binding Tasks}"><dxgn:GanttControl.Columns><dxgn:GanttColumn BindTo="Name" /><dxgn:GanttColumn BindTo="StartDate" /><dxgn:GanttColumn BindTo="FinishDate" /></dxgn:GanttControl.Columns>
</dxgn:GanttControl>

设置GanttView

GanttView指定甘特图表内容和显示

扩展所有甘特图任务当控件加载。设置AutoExpandAllNodes属性为true。可以显示和编辑和排序内容被设置视图AllowEditing和AllowSorting属性为false,像下面的代码例子

<Windowxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:GanttControlDemoApp"xmlns:dxgn="http://schemas.devexpress.com/winfx/2008/xaml/gantt" x:Class="GanttControlDemoApp.MainWindow"><Window.DataContext><local:ProjectTaskViewModel /></Window.DataContext><Grid><dxgn:GanttControl ItemsSource="{Binding Tasks}"><dxgn:GanttControl.Columns><dxgn:GanttColumn BindTo="Name" /><dxgn:GanttColumn BindTo="StartDate" /><dxgn:GanttColumn BindTo="FinishDate" /></dxgn:GanttControl.Columns><dxgn:GanttControl.View><dxgn:GanttView AutoExpandAllNodes="True" AllowEditing="False" AllowSorting="False"/></dxgn:GanttControl.View></dxgn:GanttControl></Grid>
</Window>

下面的图片演示了结果

任务依赖

每一个任务暴露了PredecessorLinks属性。属性提供了访问GanttPredecessorLink集合对象。每一个GanttPredecessorLink对象包含任务访问记录id和相对的链接类型

添加如下代码到视图模型

// the "Release the new feature" task can begin only when the "Write the docs" task is complete
Tasks[4].PredecessorLinks.Add(new GanttPredecessorLink() { PredecessorTaskId = 2, LinkType = PredecessorLinkType.FinishToStart });
// the "Release the new feature" task can begin only when the "Test the new feature" task is complete
Tasks[4].PredecessorLinks.Add(new GanttPredecessorLink() { PredecessorTaskId = 3, LinkType = PredecessorLinkType.FinishToStart });
// the "Write the docs" task can begin only when the "Write the code" task is complete
Tasks[2].PredecessorLinks.Add(new GanttPredecessorLink() { PredecessorTaskId = 1, LinkType = PredecessorLinkType.FinishToStart });
// the "Test the new feature" task can begin only when the "Write the code" task is complete
Tasks[3].PredecessorLinks.Add(new GanttPredecessorLink() { PredecessorTaskId = 1, LinkType = PredecessorLinkType.FinishToStart });

现在,GanttControl显示任务关系。如下图片显示结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/148548.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python算法——树的最大深度和最小深度

Python中的树的最大深度和最小深度算法详解 树的最大深度和最小深度是树结构中的两个关键指标&#xff0c;它们分别表示树的从根节点到最深叶子节点的最大路径长度和最小路径长度。在本文中&#xff0c;我们将深入讨论如何计算树的最大深度和最小深度&#xff0c;并提供Python…

记录将excel表无变形的弄进word里面来

之前关于这个问题记录过一篇文章&#xff1a; 将excel中的表快速复制粘贴进word中且不变形-CSDN博客 今天记录另外一种方法&#xff1a;举例表述&#xff0c;excel表如图&#xff1a; 按F12&#xff0c;出现“另存为...”对话框&#xff0c;选择“单个文件网页”&#xff0c;…

面向对象与面向过程的区别

面向对象 以对象为中心&#xff0c;把数据封装成为一个整体&#xff0c;其他数据无法直接修改它的数据&#xff0c;将问题分解成不同对象&#xff0c;然后给予对象相应的属性和行为。 面向过程 关注代码过程&#xff0c;直接一程序来处理数据&#xff0c;各模块之间有调用与…

C#_模拟鼠标操作

一、class class MouseHelper{[DllImport("user32.dll")]public static extern bool SetCursorPos(int X, int Y);[System.Runtime.InteropServices.DllImport("user32")]public static extern int mouse_event(int dwFlags, int dx, int dy, int dwData, …

大数据-之LibrA数据库系统告警处理(ALM-12055 证书文件即将过期)

告警解释 系统每天二十三点检查一次当前系统中的证书文件&#xff0c;如果当前时间距离过期时间不足告警阈值天数&#xff0c;则证书文件即将过期&#xff0c;产生该告警。告警阈值天数的配置请参考《管理员指南》的“配置证书即将过期告警阈值”章节。 当重新导入一个正常证…

oracle-buffer cache

段&#xff0c;区&#xff0c;块。 每当新建一个表&#xff0c;数据库会相应创建一个段。然后给这个段分配一个区。 一个区包含多个块。 区是oracle给段分配空间的最小单位。 块是oracle i\o的最小单位。 原则上&#xff0c;一个块包含多行数据。 dbf文件会被划分成一个一个…

Netty Review - 核心组件扫盲

文章目录 PreNetty Reactor 的工作架构图CodePOMServerClient Netty 重要组件taskQueue任务队列scheduleTaskQueue延时任务队列Future异步机制Bootstrap与ServerBootStrapgroup()channel()option()与childOption()ChannelPipelinebind()优雅地关闭EventLoopGroupChannleChannel…

今天遇到Windows 10里安装的Ubuntu(WSL)的缺点

随着技术的发展&#xff0c;越来越多开发者转向使用 Windows Subsystem for Linux&#xff08;WSL&#xff09;在 Windows 10 上进行开发&#xff0c;也就是说不用虚拟机&#xff0c;不用准备多一台电脑&#xff0c;只需要在Windows 10/11 里安装 WSL 就能体验 Linux 系统。因此…

C# Array和ArrayList有什么区别

在C#中&#xff0c;Array和ArrayList是集合类型&#xff0c;用于存储一组元素&#xff0c;但它们之间有几个关键区别&#xff1a; 类型安全&#xff1a; Array是类型安全的&#xff0c;意味着它只能存储一种特定类型的元素。例如&#xff0c;一个int[]数组只能存储int类型的元素…

邀请报名|11月24日阿里云原生 Serverless 技术实践营 深圳站

活动简介 “阿里云云原生 Serverless 技术实践营 ” 是一场以 Serverless 为主题的开发者活动&#xff0c;活动受众以关注 Serverless 技术的开发者、企业决策人、云原生领域创业者为主&#xff0c;活动形式为演讲、动手实操&#xff0c;让开发者通过一个下午的时间增进对 Ser…

how to find gcc openbug

https://gcc.gnu.org/bugzilla/query.cgi?formatadvanced

最全的接口自动化测试思路和实战:【推荐】混合测试自动化框架(关键字+数据驱动)

混合测试自动化框架(关键字数据驱动) 关键字驱动或表驱动的测试框架 这个框架需要开发数据表和关键字。这些数据表和关键字独立于执行它们的测试自动化工具&#xff0c;并可以用来“驱动&#xff02;待测应用程序和数据的测试脚本代码&#xff0c;关键字驱动测试看上去与手工测…

mount /dev/mapper/centos-root on sysroot failed处理

今天发现centos7重启开不进去系统 通过查看日志主要告警如下 修复挂载目录 xfs_repair /dev/mapper/centos-root不行加-L参数 xfs_repair -L /dev/mapper/centos-root重启 reboot

云课五分钟-0Cg++默认版本和升级-std=c++17

前篇&#xff1a; 云课五分钟-0B快速排序C示例代码-注释和编译指令 视频&#xff1a; 云课五分钟-0Cg默认版本和升级-stdc17 文本&#xff1a; 在Linux系统中&#xff0c;可以通过以下步骤升级g&#xff1a; 打开终端&#xff0c;使用root权限或者sudo权限登录。输入以下命令…

基于灰狼算法(GWO)优化的VMD参数(GWO-VMD)

代码的使用说明 基于灰狼算法优化的VMD参数 代码的原理 基于灰狼算法&#xff08;Grey Wolf Optimizer, GWO&#xff09;优化的VMD参数&#xff08;GWO-VMD&#xff09;是一种结合了GWO和VMD算法的优化方法&#xff0c;用于信号分解和特征提取。 GWO是一种基于群体智能的优化…

lv11 嵌入式开发 ARM指令集中(伪操作与混合编程) 7

目录 1 伪指令 2 伪操作 3 C和汇编的混合编程 4 ATPCS协议 1 伪指令 本身不是指令&#xff0c;编译器可以将其替换成若干条等效指令 空指令NOP 指令LDR R1, [R2] 将R2指向的内存空间中的数据读取到R1寄存器 伪指令LDR R1, 0x12345678 R1 0x12345678 LDR伪指令可以将任…

【Python 千题 —— 基础篇】输出列表中的偶数

题目描述 题目描述 依次输出列表中所有的偶数。题中有一个包含数字的列表 [10, 39, 13, 48, 32, 18, 3, 204, 592, 11]&#xff0c;使用 for 循环依次输出这个列表中所有的偶数。 输入描述 无输入。 示例 示例 ① 输出&#xff1a; 10 48 32 18 204 592输出描述 输出列…

小米真无线耳机 Air 2s产品蓝牙配对ubuntu20.04 笔记本电脑

小米真无线耳机 Air 2s产品蓝牙配对ubuntu20.04 笔记本电脑 1.我的笔记本是 22款联想拯救者y9000k&#xff0c;安装了双系统&#xff0c;ubuntu20.04。 2.打开耳机&#xff0c;按压侧面按钮2秒&#xff0c;指示灯显示白色闪烁。 3.打开ubunru20.04 系统右上角wifi的位置&…

【Go入门】 Go的http包详解

【Go入门】 Go的http包详解 前面小节介绍了Go怎么样实现了Web工作模式的一个流程&#xff0c;这一小节&#xff0c;我们将详细地解剖一下http包&#xff0c;看它到底是怎样实现整个过程的。 Go的http有两个核心功能&#xff1a;Conn、ServeMux Conn的goroutine 与我们一般编…

vulnhub靶场—matrix-breakout-2-morpheus靶机

一&#xff0c;实验环境 靶机ip&#xff1a;192.168.150.131攻击机ip&#xff1a;192.168.150.130 二&#xff0c;信息收集 arp-scan -l 扫描网段&#xff0c;寻找靶机ip 使用工具nmap进行端口扫描 nmap -A -T4 -p- 192.168.150.131 通过信息收集发现了靶机有80和81这两个…