WPF之窗体模型
编程
1. MyApp.xaml
Define Start up window(StartupUri) for the application
<Application StartupUri = “MyWindow.xaml”/>
2.MyWindow.xaml
<Window x:Class=”MyWindow” Width=”300″ Height=”200″ Title=”">
<Button Click=”ButtonClick”>
</Button>
</Window>
3.MyWindow.cs
4.myProj.csproj
5.msbuild myProj.csproj
编译过程:
Layout,Control的设定被转化为 BAML(Binary App Markup Language), 再嵌入到resources中
BAML+ C# -> exe
实验1: 查看obj目录,包含编译的中间结果:
MyWindow.cs
MyWindow.g.cs
MyWindow.baml
实验2:查看msbuild 编译时在控制台的输出
执行流程:
SourceInitialized
Activated
Loaded
ContentRendered
Deactivated/Acrivated
Closing
Closed
交互
WindowsFormsHost(将windows control放到wpf form)
ElementHost(将wpf control 放到 windows from)
HwndHost, HwndSource(与Win32和MFC窗体/控件进行交互)
Reference
www.techjie.com
