Index: Core/Plugins/src/Core.Plugins.Chart/Legend/ChartLegendView.cs =================================================================== diff -u -rbaf30f71add766acbccd7b79eea9319d7bba556f -r12be9235f5b2db3b6a390088997c332123d4e7d5 --- Core/Plugins/src/Core.Plugins.Chart/Legend/ChartLegendView.cs (.../ChartLegendView.cs) (revision baf30f71add766acbccd7b79eea9319d7bba556f) +++ Core/Plugins/src/Core.Plugins.Chart/Legend/ChartLegendView.cs (.../ChartLegendView.cs) (revision 12be9235f5b2db3b6a390088997c332123d4e7d5) @@ -85,6 +85,12 @@ { get { + var chartDataContext = treeViewControl.SelectedData as ChartDataContext; + if (chartDataContext != null) + { + return chartDataContext.WrappedData; + } + return treeViewControl.SelectedData; } } Index: Core/Plugins/test/Core.Plugins.Chart.Test/Legend/ChartLegendViewTest.cs =================================================================== diff -u -rbaf30f71add766acbccd7b79eea9319d7bba556f -r12be9235f5b2db3b6a390088997c332123d4e7d5 --- Core/Plugins/test/Core.Plugins.Chart.Test/Legend/ChartLegendViewTest.cs (.../ChartLegendViewTest.cs) (revision baf30f71add766acbccd7b79eea9319d7bba556f) +++ Core/Plugins/test/Core.Plugins.Chart.Test/Legend/ChartLegendViewTest.cs (.../ChartLegendViewTest.cs) (revision 12be9235f5b2db3b6a390088997c332123d4e7d5) @@ -137,7 +137,7 @@ [Test] [Apartment(ApartmentState.STA)] - public void Selection_Always_ReturnsSelectedNodeData() + public void Selection_NestedNodeData_ReturnsWrappedObjectData() { // Setup var mocks = new MockRepository(); @@ -163,7 +163,7 @@ object selection = view.Selection; // Assert - Assert.AreSame(chartData, ((ChartDataContext) selection).WrappedData); + Assert.AreSame(chartData, selection); } WindowsFormsTestHelper.CloseAll(); @@ -172,6 +172,39 @@ [Test] [Apartment(ApartmentState.STA)] + public void Selection_RootNodeData_ReturnsObjectData() + { + // Setup + var mocks = new MockRepository(); + var contextMenuBuilderProvider = mocks.Stub(); + mocks.ReplayAll(); + + ChartData chartData = CreateChartData(); + var chartDataCollection = new ChartDataCollection("collection"); + chartDataCollection.Add(chartData); + + using (var view = new ChartLegendView(contextMenuBuilderProvider) + { + Data = chartDataCollection + }) + { + var treeViewControl = TypeUtils.GetField(view, "treeViewControl"); + WindowsFormsTestHelper.Show(treeViewControl); + treeViewControl.TrySelectNodeForData(chartDataCollection); + + // Call + object selection = view.Selection; + + // Assert + Assert.AreSame(chartDataCollection, selection); + } + WindowsFormsTestHelper.CloseAll(); + + mocks.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] public void GivenChartLegendView_WhenSelectedNodeChanged_SelectionChangedFired() { // Given