WPF Application启动界面设置

来源:互联网 发布:电信专线网络的价格 编辑:程序博客网 时间:2024/05/21 17:50

设置WPF从不同界面启动可以通过设置“StartupUri”属性完成。

http://blog.csdn.net/bamboo_slit/article/details/7164848

设置StartupUri参数时,根路径为项目路径。下面代码是设置以项目路径下View目录里的CreateWO页面为启动界面。

[html] view plaincopy
  1. <Application x:Class="RCMS_MVVM.App"  
  2.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
  3.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
  4.              xmlns:vm="clr-namespace:RCMS_MVVM.ViewModel"  
  5.              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
  6.              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
  7.              xmlns:local="clr-namespace:RCMS_MVVM"  
  8.              <span style="color:#ff0000;">StartupUri="View/CreateWO.xaml"  
  9. </span>             mc:Ignorable="d">  
  10.       
  11.     <Application.Resources>  
  12.         <!--Global View Model Locator-->  
  13.         <vm:ViewModelLocator x:Key="Locator"  
  14.                              d:IsDataSource="True" />  
  15.   
  16.       <ObjectDataProvider x:Key="Resources" ObjectType="{x:Type local:CulturesHelper}"  
  17.                 MethodName="GetResourceInstance"/>  
  18.     <ObjectDataProvider x:Key="CultureResourcesDS" ObjectType="{x:Type local:CulturesHelper}" />  
  19.         
  20.   </Application.Resources>  
  21.       
  22. </Application>  

下面代码是设置以项目路径下MainWindow页面为启动界面。

[html] view plaincopy
  1. <Application x:Class="RCMS_MVVM.App"  
  2.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
  3.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
  4.              xmlns:vm="clr-namespace:RCMS_MVVM.ViewModel"  
  5.              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
  6.              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
  7.              xmlns:local="clr-namespace:RCMS_MVVM"  
  8.              <span style="color:#ff0000;">StartupUri="MainWindow.xaml"  
  9. </span>             mc:Ignorable="d">  
  10.       
  11.     <Application.Resources>  
  12.         <!--Global View Model Locator-->  
  13.         <vm:ViewModelLocator x:Key="Locator"  
  14.                              d:IsDataSource="True" />  
  15.   
  16.       <ObjectDataProvider x:Key="Resources" ObjectType="{x:Type local:CulturesHelper}"  
  17.                 MethodName="GetResourceInstance"/>  
  18.     <ObjectDataProvider x:Key="CultureResourcesDS" ObjectType="{x:Type local:CulturesHelper}" />  
  19.         
  20.   </Application.Resources>  
  21.       
  22. </Application>