rob_patterson42@hotmail.com Posted January 28, 2009 Report Share Posted January 28, 2009 I am using the WPF RC1 release and I seem to have issues with the the x-axis scroll bars when a secondary y-axis is added. Below is the code snippet I'm using, and I find that the only place I can successfully add a scrollbar is where it is currently. However, when I access the chart to remove the event handler with from a different application area with access to the chart using simple access such as, chart.AxisX.ScrollBar.Scroll -= new System.Windows.Controls.Primitives.ScrollEventHandler(this.ScrollingEventHandler);, the handler isn't removed properly. What is the correct order of operations to create a chart with a secondary y-axis and add a scroll bar with event handling? SeriesAttributes serData1Time = new SeriesAttributes(); serData1Time.BindingPath = "Data1"; serData1Time.BindingPathX = "ElapsedTime"; serData1Time.Fill = Brushes.Green; TrendingChart.Series.Add(serData1Time); // ********** add scroll bar here ********* TrendingChart.AxisX.ScrollBar.Height = 5.0; TrendingChart.AxisX.SetScrollView(someValue, anotherValue); TrendingChart.AxisX.ScrollBar.Scroll += new System.Windows.Controls.Primitives.ScrollEventHandler(this.ScrollingEventHandler); // secondary yAxis Axis secondaryAxis = new Axis(); secondaryAxis.Position = AxisPosition.Far; secondaryAxis.Foreground = Brushes.Red; secondaryAxis.FontSize = 10; SeriesAttributes serData2 = new SeriesAttributes(); serData2.BindingPath = "Data2"; serData2.BindingPathX = "ElapsedTime"; serData2.Fill = Brushes.Red; serData2.AxisY = secondaryAxis; TrendingChart.Series.Add(serData2); TrendingChart.ItemsSource = TrendData; TrendingChart.AxisX.Max = elapsedTimeMaximum; TrendingChart.AxisY.Max = yAxisMax; TrendingChart.AxesY[1].Max = secondaryYAxisMax; Regards, Rob Quote Link to comment Share on other sites More sharing options...
rob_patterson42@hotmail.com Posted January 28, 2009 Author Report Share Posted January 28, 2009 ...I forgot to add that I often reload the chart listed below, and on each reload I simply clear out the data and redraw the series. And it Quote Link to comment Share on other sites More sharing options...
JuanC Posted January 28, 2009 Report Share Posted January 28, 2009 Can you try to recreate the issue in a small test app? Regards, JuanC Quote Link to comment Share on other sites More sharing options...
rob_patterson42@hotmail.com Posted January 29, 2009 Author Report Share Posted January 29, 2009 When putting together an small test application to prove the error, I found the fix! I needed to move my "itemSource" binding to above setting the scrollbar view, and moving the secondary axis creation and association to the end of the logic -but after setting the scrollbar view. Thanks for the time, Rob Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.