所以我尝试同时打开最多两个应用程序,用户单击导航菜单上列出的按钮,然后应用程序在顶级应用程序的空白红色区域中打开,如下所示:
这是此页面的 xaml 代码:
<Grid Background="#d80202">
<NavigationView x:Name="Navigation">
<NavigationView.MenuItems>
<NavigationViewItem x:Name="Home" Icon="Home" Content="Home"/>
<NavigationViewItem x:Name="Colours" Icon="Edit" Content="Colours"/>
<NavigationViewItem Icon="Admin" Content="Security"/>
<NavigationViewItem Icon="World" Content="Translate"/>
</NavigationView.MenuItems>
</NavigationView>
</Grid>
以下是 mainPage 的 .cs 代码:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Debug.WriteLine(Windows.ApplicationModel.Package.Current.Id.FamilyName);
}
private void Navigation_Loaded(object sender, RoutedEventArgs args)
{
}
private async void NavigateToColoursApp_Click(object sender, RoutedEventArgs args)
{
var options = new LauncherOptions();
options.TargetApplicationPackageFamilyName = "e8731a5c-2685-436a-b3c7-983a3b74fb9a_bnk8fdhtvqpqp";
await Windows.System.Launcher.LaunchUriAsync(new Uri("Colours.xaml"), options);
}
private void Navigation_Navigate(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
NavigationViewItem item = args.SelectedItem as NavigationViewItem;
if (item != null)
{
switch (item.Content)
{
case "Home":
Frame.Navigate(typeof(MainPage));
break;
case "Colours":
Frame.Navigate(typeof(Colours));
break;
case "Translate":
Frame.Navigate(typeof(Translate));
break;
}
}
}
}
对于导航示例,这里是颜色页面的 .cs
public Colours()
{
this.InitializeComponent();
Debug.WriteLine(Windows.ApplicationModel.Package.Current.Id.FamilyName);
}
答案 0 :(得分:2)
不能在另一个应用程序“内部”打开应用程序。应用是一个独立于其他进程/应用运行的进程。
此外,Content
控件的 SplitView
属性的类型是 UIElement
,这实际上意味着您不能将其设置为 UIElement
以外的任何其他内容。由于 Window
或应用程序都不是 UIElement
,因此您必须在此处重新考虑您的方法。
与其尝试将整个应用程序包含在 SplitView
中,不如将其内容分解为一个控件,以便您可以在任何应用程序中显示和使用。