From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
HMI.UI/Controls/treegrid/Controls/TreeDataGrid.cs | 33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/HMI.UI/Controls/treegrid/Controls/TreeDataGrid.cs b/HMI.UI/Controls/treegrid/Controls/TreeDataGrid.cs
index fdd2866..8dc00d4 100644
--- a/HMI.UI/Controls/treegrid/Controls/TreeDataGrid.cs
+++ b/HMI.UI/Controls/treegrid/Controls/TreeDataGrid.cs
@@ -19,10 +19,10 @@
static TreeDataGrid()
{
- //ScrollViewer.HorizontalScrollBarVisibilityProperty
- // .OverrideMetadata(typeof(TreeDataGrid), new FrameworkPropertyMetadata(ScrollBarVisibility.Disabled));
- //ScrollViewer.VerticalScrollBarVisibilityProperty
- // .OverrideMetadata(typeof(TreeDataGrid), new FrameworkPropertyMetadata(ScrollBarVisibility.Disabled));
+ ScrollViewer.HorizontalScrollBarVisibilityProperty
+ .OverrideMetadata(typeof(TreeDataGrid), new FrameworkPropertyMetadata(ScrollBarVisibility.Disabled));
+ ScrollViewer.VerticalScrollBarVisibilityProperty
+ .OverrideMetadata(typeof(TreeDataGrid), new FrameworkPropertyMetadata(ScrollBarVisibility.Disabled));
}
protected override DependencyObject GetContainerForItemOverride()
@@ -48,21 +48,36 @@
{
if (e.OldValue != null && e.OldValue is TreeItemData oldTreeData)
{
+ oldTreeData.IsExpandedChange -= DataIsExpandedChange;
oldTreeData.VisibleChange -= DataVisiableChange;
}
if (DataContext != null && DataContext is TreeItemData treeData)
{
+ Visibility = treeData.IsVisible ? Visibility.Visible : Visibility.Collapsed;
+ treeData.IsExpandedChange += DataIsExpandedChange;
treeData.VisibleChange += DataVisiableChange;
+ }
+ }
+
+ private void DataIsExpandedChange(object sender, bool IsExpanded)
+ {
+ object parent = ItemsControl.ItemsControlFromItemContainer(this);
+ if (sender is TreeItemData tid)
+ {
+ foreach (var data in tid.Items)
+ {
+ data.IsVisible = IsExpanded;
+ }
}
}
private void DataVisiableChange(object sender, bool visiable)
{
- object parent = ItemsControl.ItemsControlFromItemContainer(this);
- if (parent != null && parent is TreeDataGrid treeDataGrid)
- {
- treeDataGrid.OnExpandedChange(visiable);
- }
+ this.Visibility = visiable ? Visibility.Visible : Visibility.Collapsed;
+ //if (parent != null && parent is TreeDataGrid treeDataGrid)
+ //{
+ // treeDataGrid.OnExpandedChange(visiable);
+ //}
}
}
}
--
Gitblit v1.9.1