mvvm结构中数据的关联----wpf

PlotView.xaml 

<Button Content="&lt;&lt;" Height="23" HorizontalAlignment="Right" Name="button2" VerticalAlignment="Center" Width="30" Click="button2_Click" Margin="0,0,40,0"/>

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();
        }

 

PlotViewModel.cs

 #region 设置info信息
        public void SetInfo(int BarNo)
        {
            .....

        }

 

在MainView.xaml

       <DataTemplate  DataType="{x:Type local:PlotViewModel}" x:Key="PlotTemplate">
            <local:PlotView  AxesStyle="{Binding Axes, Mode=TwoWay}"  PaintLine="{Binding Paint, Mode=TwoWay}" />
        </DataTemplate>

mvvm结构中数据的关联----wpf

上一篇:Windows快速启动应用高效搜索文件工具-Listary


下一篇:XE10 clientDataset 访问 DataSnap 服务端报错问题,锲而不舍找方法,终于解决了