2015-08-08 42 views
0

林包括在我的应用程序的SPLITVIEW。但我不知道如何来填补我的SPLITVIEW的内容。我读过,我应该在那里嵌入框架。所以,我有我的MainPage.xaml中,如果用户点击一个按钮menue的SPLITVIEW的含量应例如helpandabout.xaml。或我应该在内容属性中嵌套什么?我如何用不同的页面替换内容。 我现在只是尝试,如果用户按下一个按钮,但那不是这种控制背后的理念,以改变电网的知名度。 像这样:SPLITVIEW内容属性窗口普遍

<Grid x:Name="Grid1" Visibility="Visible"> </Grid> 
<Grid Visibility="Collapsed" x:Name="Grid2"> </Grid> 

,比用户在SPLITVIEW面板按下一个按钮,代码做到这一点:

Grid1.Visibility = Visibility.Collapsed; 
Grid2.Visibility = Visibility.Visible; 

而且我知道那是一个愚蠢的代码块。

回答

0

其实你可以用SPLITVIEW更换整个应用标准,创建导航等

我所做的是:从这里

1-了解导航示例: uwp navigation example

2.-在你了解它的工作原理之后,它有一些技巧,比如命令栏在应用栏之外等,你可以提取库中的所有代码。

AppShell.xaml,NavMenuItem,NavMenuListView.cs,PageHeader.xaml

3.-创建以下扩展名:

public class NavigationExtensions 
{ 

public static void Initialize<T>(List<NavMenuItem> list, NavigationFailedEventHandler OnNavigationFailed, LaunchActivatedEventArgs e) 
    { 
     AppShell shell = Window.Current.Content as AppShell; 

     // Do not repeat app initialization when the Window already has content, 
     // just ensure that the window is active 
     if (shell == null) 
     { 
      // Create a AppShell to act as the navigation context and navigate to the first page 
      shell = new AppShell(); 

      shell.NavigationList = list; 

      try 
      { 
       shell.CurrentItem = list.First(i => i.DestPage == typeof(T)); 
      } 
      catch 
      { 

      } 

      // Set the default language 
      shell.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; 

      shell.AppFrame.NavigationFailed += OnNavigationFailed; 

      if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 
      { 
       //TODO: Load state from previously suspended application 
      } 
     } 

     // Place our app shell in the current Window 
     Window.Current.Content = shell; 

     if (shell.AppFrame.Content == null) 
     { 
      // When the navigation stack isn't restored, navigate to the first page 
      // suppressing the initial entrance animation. 

      shell.AppFrame.Navigate(typeof(T), e.Arguments, new Windows.UI.Xaml.Media.Animation.SuppressNavigationTransitionInfo()); 
     } 

     // Ensure the current window is active 
     Window.Current.Activate(); 
    } 

}

4.-参考所有这一切都在你的项目和在App.xaml.cs中添加

protected override void OnLaunched(LaunchActivatedEventArgs e) 
    { 
     NavigationExtensions.Initialize<PersonalView>(Navigation.GetNavigationMenuItems(),OnNavigationFailed,e); 
    } 

其中该方法是例如:

public class Navigation 
{ 
    public static List<NavMenuItem> GetNavigationMenuItems() 
    { 
     var list = new List<NavMenuItem>(
     new[] 
     { 
      new NavMenuItem() 
      { 
       Symbol = Symbol.Contact, 
       Label = "Personal", 
       DestPage = typeof(PersonalView) 
      }, 
      new NavMenuItem() 
      { 
       Symbol = Symbol.World, 
       Label = "Countries", 
       DestPage = typeof(CountriesView) 
      }, 
      new NavMenuItem() 
      { 
       Symbol = Symbol.Setting, 
       Label = "Settings", 
       DestPage = typeof(SettingsView) 
      }, 
     }); 

     return list; 
    } 
} 
+0

谢谢你,我一直在寻找的正是这种答案的! –

+1

不客气,也有榜样,是最新的,我鼓励你跟着我的几个很好的实现 –