2
我有,我用这种方式创建我的Windows窗体视图模型:是否可以在MVVM模式中使用WindowsFormsHost?
System.Windows.Forms.DataVisualization.Charting.Chart chart = new System.Windows.Forms.DataVisualization.Charting.Chart();
我的XAML是:
<WindowsFormsHost x:Name="host" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<wfCharts:Chart x:Name="MyWinformChart" >
<wfCharts:Chart.Series>
<wfCharts:Series Name="SerieGraficoExterior" />
</wfCharts:Chart.Series>
<wfCharts:Chart.ChartAreas>
<wfCharts:ChartArea/>
</wfCharts:Chart.ChartAreas>
</wfCharts:Chart>
</WindowsFormsHost>
但我不知道这是否是可以绑定到我的看法,因为WindowsFormsHost
控件没有像ContentControl那样的Content属性,所以我不知道是否可以在MVVM模式中使用WindowsFormsHost
。我做了一些WPF尝试,后者在代码中工作,但如果可能的话,我想使用MVVM模式。
谢谢。
所以要创建图表(Windows窗体)我需要把代码放在代码隐藏? – 2014-09-01 08:41:44
当你把它放在XAML中时,控件也被创建。您可以从代码隐藏的变量名称(MyWinformChart)访问窗体控件, – sondergard 2014-09-01 08:44:51