Jump to content
Software FX Community

Adding scroll bars and event handler issue - RC1


Recommended Posts

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;


  // ********** 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.ItemsSource = TrendData;

  TrendingChart.AxisX.Max = elapsedTimeMaximum;

  TrendingChart.AxisY.Max = yAxisMax;

  TrendingChart.AxesY[1].Max = secondaryYAxisMax;



Link to comment
Share on other sites

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,


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...