Index: Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs =================================================================== diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 --- Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs (.../TreeNodeInfo.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) +++ Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs (.../TreeNodeInfo.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85) @@ -117,9 +117,10 @@ /// /// Gets or sets an action for obtaining the logic to perform after checking or unchecking the tree node. - /// The parameter represents the tree node which is checked. + /// The first parameter represents the data of the tree node. + /// The second parameter represents the data of the parent tree node. /// - public Action OnNodeChecked { get; set; } + public Action OnNodeChecked { get; set; } /// /// Gets or sets a function for checking whether or not the tree node can be dragged to another location. @@ -255,9 +256,10 @@ /// /// Gets or sets an action for obtaining the logic to perform after checking or unchecking the tree node. - /// The parameter represents the tree node which is checked. + /// The parameter represents the data of the tree node. + /// The parameter represents the data of the parent tree node. /// - public Action OnNodeChecked { get; set; } + public Action OnNodeChecked { get; set; } /// /// Gets or sets a function for checking whether or not the tree node can be dragged to another location. @@ -337,8 +339,8 @@ ? tag => treeNodeInfo.IsChecked((TData) tag) : (Func) null, OnNodeChecked = treeNodeInfo.OnNodeChecked != null - ? sourceNode => treeNodeInfo.OnNodeChecked(sourceNode) - : (Action) null, + ? (tag, parentTag) => treeNodeInfo.OnNodeChecked((TData) tag, parentTag) + : (Action) null, CanDrag = treeNodeInfo.CanDrag != null ? (tag, sourceNode) => treeNodeInfo.CanDrag((TData) tag, sourceNode) : (Func) null, Index: Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs =================================================================== diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 --- Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) +++ Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85) @@ -550,7 +550,7 @@ var treeNodeInfo = GetTreeNodeInfoForData(e.Node.Tag); if (treeNodeInfo.OnNodeChecked != null) { - treeNodeInfo.OnNodeChecked(e.Node); + treeNodeInfo.OnNodeChecked(e.Node.Tag, e.Node.Parent != null ? e.Node.Parent.Tag : null); } } Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs =================================================================== diff -u -rc68064014494505f833de7749ee7b3d879f723d6 -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision c68064014494505f833de7749ee7b3d879f723d6) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85) @@ -53,7 +53,7 @@ CanDrag = (pointData, sourceNode) => DragOperations.Move, CanCheck = pointData => true, IsChecked = pointData => pointData.IsVisible, - OnNodeChecked = PointBasedChartDataOnNodeChecked + OnNodeChecked = PointDataOnNodeChecked }); treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo @@ -63,7 +63,7 @@ CanDrag = (lineData, sourceNode) => DragOperations.Move, CanCheck = lineData => true, IsChecked = lineData => lineData.IsVisible, - OnNodeChecked = PointBasedChartDataOnNodeChecked + OnNodeChecked = LineDataOnNodeChecked }); treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo @@ -73,7 +73,7 @@ CanDrag = (areaData, sourceNode) => DragOperations.Move, CanCheck = areaData => true, IsChecked = areaData => areaData.IsVisible, - OnNodeChecked = PointBasedChartDataOnNodeChecked + OnNodeChecked = AreaDataOnNodeChecked }); treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo @@ -106,19 +106,30 @@ # region ChartData - private void PointBasedChartDataOnNodeChecked(TreeNode node) + private void PointDataOnNodeChecked(PointData pointData, object parentData) { - var pointBasedChartData = node.Tag as PointBasedChartData; - if (pointBasedChartData != null) - { - pointBasedChartData.IsVisible = node.Checked; - pointBasedChartData.NotifyObservers(); + PointBasedChartDataOnNodeChecked(pointData, parentData); + } - var parentData = node.Parent != null ? node.Parent.Tag as IObservable : null; - if (parentData != null) - { - parentData.NotifyObservers(); - } + private void LineDataOnNodeChecked(LineData lineData, object parentData) + { + PointBasedChartDataOnNodeChecked(lineData, parentData); + } + + private void AreaDataOnNodeChecked(AreaData areaData, object parentData) + { + PointBasedChartDataOnNodeChecked(areaData, parentData); + } + + private void PointBasedChartDataOnNodeChecked(PointBasedChartData pointBasedChartData, object parentData) + { + pointBasedChartData.IsVisible = !pointBasedChartData.IsVisible; + pointBasedChartData.NotifyObservers(); + + var observableParent = parentData as IObservable; + if (observableParent != null) + { + observableParent.NotifyObservers(); } } Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/AreaDataTreeNodeInfoTest.cs =================================================================== diff -u -rb3883ecc0719d5df114cacc849796c0ca420507d -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/AreaDataTreeNodeInfoTest.cs (.../AreaDataTreeNodeInfoTest.cs) (revision b3883ecc0719d5df114cacc849796c0ca420507d) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/AreaDataTreeNodeInfoTest.cs (.../AreaDataTreeNodeInfoTest.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85) @@ -145,18 +145,13 @@ { // Setup var areaData = mocks.StrictMock(Enumerable.Empty>()); - var areaDataTreeNode = new TreeNode - { - Tag = areaData - }; mocks.ReplayAll(); areaData.IsVisible = initialVisibleState; - areaDataTreeNode.Checked = !initialVisibleState; // Call - info.OnNodeChecked(areaDataTreeNode); + info.OnNodeChecked(areaData, null); // Assert Assert.AreEqual(!initialVisibleState, areaData.IsVisible); @@ -171,25 +166,15 @@ // Setup var observable = mocks.StrictMock(); var areaData = mocks.StrictMock(Enumerable.Empty>()); - var areaDataTreeNode = new TreeNode - { - Tag = areaData - }; - var parentNode = new TreeNode - { - Tag = observable - }; observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); areaData.IsVisible = initialVisibleState; - parentNode.Nodes.Add(areaDataTreeNode); - areaDataTreeNode.Checked = !initialVisibleState; // Call - info.OnNodeChecked(areaDataTreeNode); + info.OnNodeChecked(areaData, observable); // Assert Assert.AreEqual(!initialVisibleState, areaData.IsVisible); Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LineDataTreeNodeInfoTest.cs =================================================================== diff -u -r96fff35cedc43c8be2da620efa3d1b9cb3e42238 -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LineDataTreeNodeInfoTest.cs (.../LineDataTreeNodeInfoTest.cs) (revision 96fff35cedc43c8be2da620efa3d1b9cb3e42238) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LineDataTreeNodeInfoTest.cs (.../LineDataTreeNodeInfoTest.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85) @@ -145,18 +145,13 @@ { // Setup var lineData = mocks.StrictMock(Enumerable.Empty>()); - var lineDataTreeNode = new TreeNode - { - Tag = lineData - }; mocks.ReplayAll(); lineData.IsVisible = initialVisibleState; - lineDataTreeNode.Checked = !initialVisibleState; // Call - info.OnNodeChecked(lineDataTreeNode); + info.OnNodeChecked(lineData, null); // Assert Assert.AreEqual(!initialVisibleState, lineData.IsVisible); @@ -171,25 +166,15 @@ // Setup var observable = mocks.StrictMock(); var lineData = mocks.StrictMock(Enumerable.Empty>()); - var lineDataTreeNode = new TreeNode - { - Tag = lineData - }; - var parentNode = new TreeNode - { - Tag = observable - }; observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); lineData.IsVisible = initialVisibleState; - parentNode.Nodes.Add(lineDataTreeNode); - lineDataTreeNode.Checked = !initialVisibleState; // Call - info.OnNodeChecked(lineDataTreeNode); + info.OnNodeChecked(lineData, observable); // Assert Assert.AreEqual(!initialVisibleState, lineData.IsVisible); Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/PointDataTreeNodeInfoTest.cs =================================================================== diff -u -rb3883ecc0719d5df114cacc849796c0ca420507d -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/PointDataTreeNodeInfoTest.cs (.../PointDataTreeNodeInfoTest.cs) (revision b3883ecc0719d5df114cacc849796c0ca420507d) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/PointDataTreeNodeInfoTest.cs (.../PointDataTreeNodeInfoTest.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85) @@ -145,18 +145,13 @@ { // Setup var pointData = mocks.StrictMock(Enumerable.Empty>()); - var pointDataTreeNode = new TreeNode - { - Tag = pointData - }; mocks.ReplayAll(); pointData.IsVisible = initialVisibleState; - pointDataTreeNode.Checked = !initialVisibleState; // Call - info.OnNodeChecked(pointDataTreeNode); + info.OnNodeChecked(pointData, null); // Assert Assert.AreEqual(!initialVisibleState, pointData.IsVisible); @@ -171,25 +166,15 @@ // Setup var observable = mocks.StrictMock(); var pointData = mocks.StrictMock(Enumerable.Empty>()); - var pointDataTreeNode = new TreeNode - { - Tag = pointData - }; - var parentNode = new TreeNode - { - Tag = observable - }; observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); pointData.IsVisible = initialVisibleState; - parentNode.Nodes.Add(pointDataTreeNode); - pointDataTreeNode.Checked = !initialVisibleState; // Call - info.OnNodeChecked(pointDataTreeNode); + info.OnNodeChecked(pointData, observable); // Assert Assert.AreEqual(!initialVisibleState, pointData.IsVisible);