media media - 9 days ago 8
C# Question

ScrollViewer does not work properly

I have the following code in

WPF
:


<telerikNavigation:RadTileViewItem Header="New Synonyms">
<ScrollViewer>
<Grid ScrollViewer.CanContentScroll="True">

<telerik:RadCartesianChart>
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:CategoricalAxis />
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis/>
</telerik:RadCartesianChart.VerticalAxis>

<telerik:RadCartesianChart.Series>
<telerik:BarSeries Name="barSeriesNewSynonyms">
<telerik:BarSeries.DataPoints>
<telerik:CategoricalDataPoint Category="hello" Value="10" />
<telerik:CategoricalDataPoint Category="hi" Value="5" />
</telerik:BarSeries.DataPoints>
</telerik:BarSeries>
</telerik:RadCartesianChart.Series>
</telerik:RadCartesianChart>


</Grid>
</ScrollViewer>
</telerikNavigation:RadTileViewItem>


and it seems like this:
enter image description here

As you can see the
scrollViewer
does not work. I also have change the above code in a way that the
scrollviewer
was ebmeded inside the
Grid
but it gave me the same result. How can I have scroll to have the entire content embeded in the grid that all of them can be visible.

Edit:

For clarifying more, whenever you use your typical browser, if the content does not fit to your screen, the browser uses scorll bars to fit them. In my code I want to use
ScrollViewer
to fit the items inside it. but as you can see the scrollviewer does not appear and does not work and I do not know the reason. The following image shows that every thing is embeded without the need of scroll, but the size changes and I need to have scroll bars.

enter image description here
I update the content of the chart by using the following
C#
code:

this.barSeriesOldSynonyms.DataPoints.Clear();
foreach (var it in osr.previousMeanings)
this.barSeriesOldSynonyms.DataPoints.Add(new Telerik.Charting.CategoricalDataPoint() { Category = it.word.ToString(), Value = it.frequency });

Answer

RadCartesianChart seems to have its own scrolling behaviours, look at: http://docs.telerik.com/devtools/wpf/controls/radchartview/features/behaviors/panzoom

In summary you can set

<telerikChart:RadCartesianChart.Behaviors>
   <telerikChart:ChartPanAndZoomBehavior PanMode="Both" />
</telerikChart:RadCartesianChart.Behaviors>

to get 2 scrollbars.

Comments