Skip to content

Commit

Permalink
make some nav frame to start with
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertK66 committed Aug 11, 2023
1 parent 7284e44 commit 3d71411
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 12 deletions.
2 changes: 2 additions & 0 deletions MyHomeAudio/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Foundation.Metadata;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand All @@ -38,6 +39,7 @@ public App() {
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) {
m_window = new MainWindow();
//m_window.ExtendsContentIntoTitleBar = true;
m_window.Activate();
}

Expand Down
26 changes: 21 additions & 5 deletions MyHomeAudio/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
<AppBarButton x:Name="myIconButton" Icon="Like" Label="Like"/>
</StackPanel>
<NavigationView ItemInvoked="NavigationView_ItemInvoked" IsBackButtonVisible="Collapsed" Header="This is Header Text" >
<NavigationView.MenuItems>
<NavigationViewItem Icon="Play" Content="Menu Item1" Tag="SamplePage1" />
<NavigationViewItem Icon="Save" Content="Menu Item2" Tag="SamplePage2" >
<NavigationViewItem.MenuItems>
<NavigationViewItem Content="Mail" Icon="Mail" Tag="SamplePage2.1"/>
<NavigationViewItem Content="Calendar" Icon="Calendar" Tag="SamplePage2.2">
<NavigationViewItem.MenuItems>
<NavigationViewItem Content="Mail" Icon="Manage" Tag="SamplePage2.2.1"/>
<NavigationViewItem Content="Calendar" Icon="Camera" Tag="SamplePage2.2.2"/>
</NavigationViewItem.MenuItems>
</NavigationViewItem>
</NavigationViewItem.MenuItems>
</NavigationViewItem>
<NavigationViewItem Icon="Refresh" Content="Menu Item3" Tag="SamplePage3" />
<NavigationViewItem Icon="Download" Content="Menu Item4" Tag="SamplePage4" />
</NavigationView.MenuItems>

<Frame x:Name="ContentFrame" />

</NavigationView>
</Window>
38 changes: 34 additions & 4 deletions MyHomeAudio/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
using Microsoft.UI.Windowing; // Needed for AppWindow.
using WinRT.Interop; // Needed for XAML/HWND interop.
using Windows.UI;
using System.Net.NetworkInformation;
using MyHomeAudio.pages;

//using AppUIBasics.Common;
//using AppUIBasics.Data;
//using AppUIBasics.Helper;
//using System.Text.RegularExpressions;
//using System.Threading.Tasks;
//using Windows.ApplicationModel;
//using Windows.ApplicationModel.Activation;
//using Windows.ApplicationModel.Core;
//using Windows.Foundation.Metadata;
//using Windows.System.Profile;
//using WinUIGallery.DesktopWap.DataModel;
//using WASDK = Microsoft.WindowsAppSDK;



// To learn more about WinUI, the WinUI project structure,
Expand All @@ -25,21 +41,35 @@ namespace MyHomeAudio {
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>


public sealed partial class MainWindow : Window {

private AppWindow m_AppWindow;
public MainWindow() {
this.InitializeComponent();
AppWindow.Title = "My Audio - Cast Application";
AppWindow.TitleBar.IconShowOptions = IconShowOptions.HideIconAndSystemMenu;
AppWindow.TitleBar.BackgroundColor = Colors.Bisque;
AppWindow.TitleBar.ButtonBackgroundColor = Colors.Bisque;

}

private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args) {
if (args.IsSettingsInvoked) {
sender.AlwaysShowHeader = false;
//ContentFrame.Navigate(typeof(SettingsPage));
ContentFrame.Content = new SettingsPage();
} else {
sender.AlwaysShowHeader = true;
string selectedItemTag = (String)args.InvokedItem;
sender.Header = "Sample Page " + selectedItemTag;
//ContentFrame.Navigate(typeof(ContentPage));
ContentFrame.Content = new ContentPage();
}
}

private void myButton_Click(object sender, RoutedEventArgs e) {
myButton.Content = "Clicked";
private void NavigationView_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) {
ContentFrame.GoBack();
}
}
}
22 changes: 19 additions & 3 deletions MyHomeAudio/MyHomeAudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
</PropertyGroup>


<PropertyGroup>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
<PropertyGroup>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>


<ItemGroup>
<None Remove="pages\ContentPage.xaml" />
<None Remove="pages\SettingsPage.xaml" />
</ItemGroup>


<ItemGroup>
Expand All @@ -52,6 +58,16 @@
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<ItemGroup>
<Page Update="pages\ContentPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="pages\SettingsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Expand Down
6 changes: 6 additions & 0 deletions MyHomeAudio/MyHomeAudio.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
<None Update="Package.appxmanifest">
<SubType>Designer</SubType>
</None>
<Page Update="pages\ContentPage.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="pages\SettingsPage.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions MyHomeAudio/pages/ContentPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="MyHomeAudio.pages.ContentPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyHomeAudio.pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
NavigationCacheMode="Enabled">
<Grid>
<TextBox Text="Content is here"/>
</Grid>
</Page>
28 changes: 28 additions & 0 deletions MyHomeAudio/pages/ContentPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 MyHomeAudio.pages {
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ContentPage : Page {
public ContentPage() {
this.InitializeComponent();
}
}
}
16 changes: 16 additions & 0 deletions MyHomeAudio/pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="MyHomeAudio.pages.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyHomeAudio.pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
NavigationCacheMode="Enabled"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<TextBlock>Hi Page AStting</TextBlock>
</Grid>
</Page>
28 changes: 28 additions & 0 deletions MyHomeAudio/pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 MyHomeAudio.pages {
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SettingsPage : Page {
public SettingsPage() {
this.InitializeComponent();
}
}
}
1 change: 1 addition & 0 deletions WinGuiPackaged/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar

var mvm = new MainViewModel(loggerFactory, logVm);
m_window = new MainWindow() { AnyViewModel = mvm };
//m_window.ExtendsContentIntoTitleBar = true;
m_window.Activate();


Expand Down

0 comments on commit 3d71411

Please sign in to comment.