Browse Source

Add LaunchPage and NavigationView layout

pull/5/head
Ionite 2 years ago
parent
commit
eee5f09c86
No known key found for this signature in database
  1. 17
      StabilityMatrix/LaunchPage.xaml
  2. 36
      StabilityMatrix/LaunchPage.xaml.cs
  3. 20
      StabilityMatrix/MainWindow.xaml
  4. 40
      StabilityMatrix/MainWindow.xaml.cs
  5. 6
      StabilityMatrix/StabilityMatrix.csproj

17
StabilityMatrix/LaunchPage.xaml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="StabilityMatrix.LaunchPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:StabilityMatrix"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Button x:Name="LaunchButton" Content="Launch" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Click="LaunchButton_OnClick"/>
</Grid>
</Page>

36
StabilityMatrix/LaunchPage.xaml.cs

@ -0,0 +1,36 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace StabilityMatrix
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class LaunchPage : Page
{
public LaunchPage()
{
this.InitializeComponent();
}
private void LaunchButton_OnClick(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
}
}
}

20
StabilityMatrix/MainWindow.xaml

@ -7,13 +7,17 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <NavigationView
<Grid.RowDefinitions> x:Name="MainNavigationView"
<RowDefinition Height="Auto"/> Loaded="MainNavigationView_OnLoaded"
<RowDefinition Height="*"/> SelectionChanged="MainNavigationView_OnSelectionChanged"
</Grid.RowDefinitions> Header="Stability Matrix">
<Button x:Name="ButtonNavigate" Grid.Row="0" Content="InstallPage" Click="ButtonNavigate_OnClick"/> <NavigationView.MenuItems>
<Frame x:Name="ContentFrame" Grid.Row="1"/> <NavigationViewItem Content="Launch" Tag="LaunchPage" />
</Grid> <NavigationViewItem Content="Install" Tag="InstallPage" />
</NavigationView.MenuItems>
<Frame x:Name="ContentFrame"/>
</NavigationView>
</Window> </Window>

40
StabilityMatrix/MainWindow.xaml.cs

@ -12,6 +12,7 @@ using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime; using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation; using Windows.Foundation;
using Windows.Foundation.Collections; using Windows.Foundation.Collections;
using WinRT.Interop;
namespace StabilityMatrix namespace StabilityMatrix
{ {
@ -26,9 +27,46 @@ namespace StabilityMatrix
} }
private void ButtonNavigate_OnClick(object sender, RoutedEventArgs e) private void ButtonNavInstallPage_OnClick(object sender, RoutedEventArgs e)
{ {
ContentFrame.Navigate(typeof(InstallPage)); ContentFrame.Navigate(typeof(InstallPage));
} }
private void ButtonNavLaunchPage_OnClick(object sender, RoutedEventArgs e)
{
ContentFrame.Navigate(typeof(LaunchPage));
}
private void MainNavigationView_OnLoaded(object sender, RoutedEventArgs e)
{
var home = MainNavigationView.MenuItems.OfType<NavigationViewItem>().First();
SetCurrentNavigationViewItem(home);
}
private void MainNavigationView_OnSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
SetCurrentNavigationViewItem(args.SelectedItemContainer as NavigationViewItem);
}
private void SetCurrentNavigationViewItem(NavigationViewItem item)
{
if (item == null || item.Tag == null) return;
var tag = item.Tag.ToString();
switch (tag)
{
case "InstallPage":
ContentFrame.Navigate(typeof(InstallPage));
break;
case "LaunchPage":
ContentFrame.Navigate(typeof(LaunchPage));
break;
default:
throw new ArgumentException($"Invalid tag: {tag}");
}
MainNavigationView.Header = item.Content;
MainNavigationView.SelectedItem = item;
}
} }
} }

6
StabilityMatrix/StabilityMatrix.csproj

@ -13,6 +13,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="InstallPage.xaml" /> <None Remove="InstallPage.xaml" />
<None Remove="LaunchPage.xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -39,6 +40,11 @@
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> <ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" /> <ProjectCapability Include="Msix" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Page Update="LaunchPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Page Update="InstallPage.xaml"> <Page Update="InstallPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

Loading…
Cancel
Save