最近做MVVM框架下的项目,跟正常框架略微不同,XAML中不写入各种逻辑,均挪到BussinessMgt下。
在网上找了一会,感觉都不合适,我就自己整理一下。
项目结构如下:
在MainWindow.xaml页面点击一个按钮,弹出新的窗体。
View中页面
<Window x:Class="demo.View.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="300">
<Grid>
<Button Content="Abort" HorizontalAlignment="Left" x:Name="Proc_abort"
Margin="20,20,0,0" Height="40" Command="{Binding m_procedureMgt.AbortExam_Click}" VerticalAlignment="Top" Width="120" />
</Grid>
</Window>
View 子页面
<UserControl x:Class="demo.View.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Grid>
</Grid>
</UserControl>
分两种情况:
一种:页面是<Window>
Window3 a = new Window3();
a.Show();
另一种:页面<UserControl>
var window = new Window();//Windows窗体
Window1 jks = new Window1(); //UserControl写的界面
window.Content = jks;
window.Show();