本文章已收录于:
设置WPF从不同界面启动可以通过设置“StartupUri”属性完成。
http://blog.csdn.net/bamboo_slit/article/details/7164848
设置StartupUri参数时,根路径为项目路径。下面代码是设置以项目路径下View目录里的CreateWO页面为启动界面。
- <Application x:Class="RCMS_MVVM.App"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:vm="clr-namespace:RCMS_MVVM.ViewModel"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:RCMS_MVVM"
- <span style="color:#ff0000;">StartupUri="View/CreateWO.xaml"
- </span> mc:Ignorable="d">
- <Application.Resources>
- <!--Global View Model Locator-->
- <vm:ViewModelLocator x:Key="Locator"
- d:IsDataSource="True" />
- <ObjectDataProvider x:Key="Resources" ObjectType="{x:Type local:CulturesHelper}"
- MethodName="GetResourceInstance"/>
- <ObjectDataProvider x:Key="CultureResourcesDS" ObjectType="{x:Type local:CulturesHelper}" />
- </Application.Resources>
- </Application>
下面代码是设置以项目路径下MainWindow页面为启动界面。
- <Application x:Class="RCMS_MVVM.App"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:vm="clr-namespace:RCMS_MVVM.ViewModel"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:RCMS_MVVM"
- <span style="color:#ff0000;">StartupUri="MainWindow.xaml"
- </span> mc:Ignorable="d">
- <Application.Resources>
- <!--Global View Model Locator-->
- <vm:ViewModelLocator x:Key="Locator"
- d:IsDataSource="True" />
- <ObjectDataProvider x:Key="Resources" ObjectType="{x:Type local:CulturesHelper}"
- MethodName="GetResourceInstance"/>
- <ObjectDataProvider x:Key="CultureResourcesDS" ObjectType="{x:Type local:CulturesHelper}" />
- </Application.Resources>
- </Application>