1.在视图中PlotView.xaml
<Button Content="<<" Height="23" HorizontalAlignment="Right" Name="button2" VerticalAlignment="Center" Width="30" Click="button2_Click" Margin="0,0,40,0"/>
2.在视图的CS文件中PlotView.xaml.cs
private int SelectedBarNo = -1;
private void button2_Click(object sender, RoutedEventArgs e)
{
PlotViewModel pvm = this.DataContext as PlotViewModel;
SelectedBarNo = -1;
if (pvm != null)
{
pvm.BarNo = SelectedBarNo;
pvm.SetInfo(SelectedBarNo);
}
tChart1.Page.Previous();
if (tChart1.Series.Count > 0)
tChart1.Series[0].Repaint();
}
3.在ViewModel里PlotViewModel.cs
#region 设置info信息
public void SetInfo(int BarNo)
{
.....
}
#region override Function
public override DataTemplate GetTemplate()
{
return ViewTemplate.This.PlotTemplate;
}
#endregion
4.在MainView.xaml
<DataTemplate DataType="{x:Type local:PlotViewModel}" x:Key="PlotTemplate">
<local:PlotView AxesStyle="{Binding Axes, Mode=TwoWay}" PaintLine="{Binding Paint, Mode=TwoWay}" />
</DataTemplate>