Hi! I develop Prism 6 WPF MVVM application. I defined an ObservableCollection instance in Model, please see below:
public class DeviceStatusModel
{
#region Constructors
public DeviceStatusModel()
{
SeriesData = new ObservableCollection<short>();
SeriesData.Add(20);
SeriesData.Add(30);
SeriesData.Add(50);
SeriesData.Add(10);
SeriesData.Add(60);
SeriesData.Add(40);
SeriesData.Add(20);
SeriesData.Add(80);
}
#endregion
#region Properties
public ObservableCollection<short> SeriesData { get; set; }
#endregion
}
Then in ViewModel I defined the property of type of DeviceStatusModel. Please see below:
public class DeviceStatusViewModel : BindableBase
{
#region Fields
private DeviceStatusModel _deviceStatusModel;
#endregion
#region Constructors
public DeviceStatusViewModel()
{
this.DeviceStatusModel = new DeviceStatusModel();
}
#endregion
#region Properties
public DeviceStatusModel DeviceStatusModel
{
get { return this._deviceStatusModel; }
set { this.SetProperty(ref this._deviceStatusModel, value); }
}
#endregion
}
Then in View I wrote the next XAML, please see below:
<UserControl x:Class="DeviceStatus.Views.DeviceStatusView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
prism:ViewModelLocator.AutoWireViewModel="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<telerik:RadCartesianChart Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Margin="6,7,0,0" VerticalAlignment="Top">
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:LinearAxis/>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis/>
</telerik:RadCartesianChart.VerticalAxis>
<telerik:ScatterLineSeries ItemsSource="{Binding DeviceStatusModel.SeriesData}"/>
</telerik:RadCartesianChart>
</Grid>
</UserControl>
And eventually when aplication runs I see only next poor picture, please see "ChartViewScreenShot.PNG" file attached.