I been stack for the last few days trying to figure out the SilverLight 4 LineSeries graph, for some strange reason the graph being displayed but the line not being displayed. I am pretty sure that my mistake is something very basic but I been straggling to pinpoint the problem by myself.
Bellow is the code that I having problem with.
<toolkit:Chart HorizontalAlignment="Left" x:Name="chartLine" Margin="31,35,0,0" Title="Chart for test" VerticalAlignment="Top" Height="233" Width="309">
<toolkit:LineSeries IsSelectionEnabled="True" HorizontalAlignment="Left" DependentValuePath="Y" IndependentValuePath="X" Margin="195,49,0,0" Name="lineSeries1" VerticalAlignment="Top" Height="78" Width="130">
<toolkit:LineSeries.ItemsSource>
<PointCollection>
<Point>1,10</Point>
<Point>2,20</Point>
<Point>3,30</Point>
<Point>4,40</Point>
</PointCollection>
</toolkit:LineSeries.ItemsSource> 开发者_运维问答
</toolkit:LineSeries>
</toolkit:Chart>
I would also apreciate if anyone can point me to some code example with scrollable graph on Silverlight.
Thank you in advance.
Here's the corrected XAML. Your problem is the HorizontalAlignment/VerticalAlignment/Margin/Width/Height you have set in the LineSeries. Removing these fixes the problem.
Here's the complete XAML which shows the Chart with the lines properly placed.
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<toolkit:Chart HorizontalAlignment="Left" x:Name="chartLine" Margin="31,35,0,0" Title="Chart for test" VerticalAlignment="Top" Height="233" Width="309">
<toolkit:LineSeries IsSelectionEnabled="True" DependentValuePath="Y" IndependentValuePath="X" Name="lineSeries1">
<toolkit:LineSeries.ItemsSource>
<PointCollection>
<Point>1,10</Point>
<Point>2,20</Point>
<Point>3,30</Point>
<Point>4,40</Point>
</PointCollection>
</toolkit:LineSeries.ItemsSource>
</toolkit:LineSeries>
</toolkit:Chart>
</Grid>
</UserControl>
精彩评论