<Application x:Class="ViewControl.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
这个里面的StartupUri就是设置起始页的
加载效果图:
public MainWindow(string xamlFile)
{
InitializeComponent()
DependencyObject rootElement
using (FileStream fs = new FileStream(xamlFile, FileMode.Open))
{
rootElement = (DependencyObject)XamlReader.Load(fs)
}
Content = rootElement
//查找控件(方法一)
button1 = (Button) LogicalTreeHelper.FindLogicalNode(rootElement, "button1")
修改app.xaml.cs里的启动项
保存功能:
换成Create可以覆盖保存文件,不会重复而报错。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)