Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of Concept: AppWindowPresenter page #1588

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions WinUIGallery/ControlPages/AppWindowPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="WinUIGallery.ControlPages.AppWindowPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUIGallery"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<StackPanel>
<local:ControlExample HeaderText="AppWindow with OverlappedPresenter">
<Button Click="Button_Click">Create new Window with OverlappedPresenter</Button>
</local:ControlExample>

<local:ControlExample HeaderText="AppWindow with FullScreenPresenter">
<Button x:Name="CreateWithFullScreenPresenterButton" Click="CreateWithFullScreenPresenterButton_Click">
Create new Window with FullScreenPresenter
</Button>
</local:ControlExample>

<local:ControlExample HeaderText="AppWindow with CompactOverlayPresenter">
<DropDownButton x:Name="CreateWithCompactOverlayPresenterButton">
Create new Window with CompactOverlayPresenter
<DropDownButton.Flyout>
<MenuFlyout Placement="Bottom">
<MenuFlyoutItem Text="Large size" Tag="Large" Click="CreateWithCompactOverlayPresenterMenu_Click"/>
<MenuFlyoutItem Text="Medium size" Tag="Medium" Click="CreateWithCompactOverlayPresenterMenu_Click"/>
<MenuFlyoutItem Text="Small size" Tag="Small" Click="CreateWithCompactOverlayPresenterMenu_Click"/>
</MenuFlyout>
</DropDownButton.Flyout>
</DropDownButton>
</local:ControlExample>
</StackPanel>
</Page>
58 changes: 58 additions & 0 deletions WinUIGallery/ControlPages/AppWindowPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
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 Windows.Foundation;
using Windows.Foundation.Collections;
using WinUIGallery.SamplePages;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace WinUIGallery.ControlPages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class AppWindowPage : Page
{
public AppWindowPage()
{
this.InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
new SampleOverlappedPresenterWindow().Activate();
}

private void CreateWithFullScreenPresenterButton_Click(object sender, RoutedEventArgs e)
{
new SampleFullScreenPresenterWindow().Activate();
}

private void CreateWithCompactOverlayPresenterMenu_Click(object sender, RoutedEventArgs e)
{
switch((sender as MenuFlyoutItem).Tag)
{
case "Large":
new SampleCompactOverlayPresenterWindow(Microsoft.UI.Windowing.CompactOverlaySize.Large).Activate();
break;
case "Medium":
new SampleCompactOverlayPresenterWindow(Microsoft.UI.Windowing.CompactOverlaySize.Medium).Activate();
break;
case "Small":
new SampleCompactOverlayPresenterWindow(Microsoft.UI.Windowing.CompactOverlaySize.Small).Activate();
break;
}
}
}
}
58 changes: 38 additions & 20 deletions WinUIGallery/DataModel/ControlInfoData.json
Original file line number Diff line number Diff line change
Expand Up @@ -2843,26 +2843,44 @@
]
},
{
"UniqueId": "TitleBar",
"Title": "TitleBar",
"ApiNamespace": "Microsoft.UI.Xaml",
"Subtitle": "An example showing a custom UIElement used as the titlebar for the app's window.",
"ImagePath": "ms-appx:///Assets/ControlImages/TitleBar.png",
"Description": "This sample shows how to use a custom titlebar for the app's window. There are 2 ways of doing it: using default titlebar and setting an UIElement as a custom titlebar.",
"Content": "<p>Look at the <i>TitleBarPage.xaml</i> file in Visual Studio to see the full code for this page.</p>",
"IsUpdated": true,
"Docs": [
{
"Title": "TitleBar - API",
"Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window.extendscontentintotitlebar"
},
{
"Title": "Guidelines",
"Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window"
}
],
"RelatedControls": [
]
"UniqueId": "TitleBar",
"Title": "TitleBar",
"ApiNamespace": "Microsoft.UI.Xaml",
"Subtitle": "An example showing a custom UIElement used as the titlebar for the app's window.",
"ImagePath": "ms-appx:///Assets/ControlImages/TitleBar.png",
"Description": "This sample shows how to use a custom titlebar for the app's window. There are 2 ways of doing it: using default titlebar and setting an UIElement as a custom titlebar.",
"Content": "<p>Look at the <i>TitleBarPage.xaml</i> file in Visual Studio to see the full code for this page.</p>",
"IsUpdated": true,
"Docs": [
{
"Title": "TitleBar - API",
"Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window.extendscontentintotitlebar"
},
{
"Title": "Guidelines",
"Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window"
}
],
"RelatedControls": [
]
},
{
"UniqueId": "AppWindow",
"Title": "AppWindow",
"ApiNamespace": "Microsoft.UI.Windowing",
"Subtitle": "",
"ImagePath": "ms-appx:///Assets/ControlImages/TitleBar.png",
"Description": "This sample shows different functionalities of AppWindow and its corresponding Presenter.",
"Docs": [
{
"Title": "AppWindow - API",
"Uri": "https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindow"
},
{
"Title": "OverlappedPresenter - API",
"Uri": "https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.overlappedpresenter"
}
]
}
]
},
Expand Down
20 changes: 20 additions & 0 deletions WinUIGallery/SamplePages/SampleCompactOverlayPresenterWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="WinUIGallery.SamplePages.SampleCompactOverlayPresenterWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUIGallery.SamplePages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<StackPanel Spacing="20" VerticalAlignment="Center">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16">
Current CompactOverlaySize:
<Run x:Name="SizeText"/>
</TextBlock>

<ToggleButton Click="ToggleButton_Click" HorizontalAlignment="Center">ExtendsContentIntoTitleBar</ToggleButton>
</StackPanel>

</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Windowing;
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 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 WinUIGallery.SamplePages
{
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SampleCompactOverlayPresenterWindow : Window
{
public SampleCompactOverlayPresenterWindow(CompactOverlaySize size)
{
this.InitializeComponent();
var presenter = CompactOverlayPresenter.Create();
presenter.InitialSize = size;
AppWindow.SetPresenter(presenter);
SizeText.Text = sizeText(size);
}

private static string sizeText(CompactOverlaySize size)
{
switch (size)
{
case CompactOverlaySize.Large: return "Large";
case CompactOverlaySize.Medium: return "Medium";
case CompactOverlaySize.Small: return "Small";
}
return "";
}

private void ToggleButton_Click(object sender, RoutedEventArgs e)
{
ExtendsContentIntoTitleBar = !ExtendsContentIntoTitleBar;
}
}
}
14 changes: 14 additions & 0 deletions WinUIGallery/SamplePages/SampleFullScreenPresenterWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="WinUIGallery.SamplePages.SampleFullScreenPresenterWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUIGallery.SamplePages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="CloseWindowButton" Click="CloseWindowButton_Click">Close Window</Button>
</Grid>
</Window>
38 changes: 38 additions & 0 deletions WinUIGallery/SamplePages/SampleFullScreenPresenterWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
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 Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Windowing;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace WinUIGallery.SamplePages
{
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SampleFullScreenPresenterWindow : Window
{
public SampleFullScreenPresenterWindow()
{
this.InitializeComponent();
AppWindow.SetPresenter(FullScreenPresenter.Create());
}

private void CloseWindowButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}
22 changes: 22 additions & 0 deletions WinUIGallery/SamplePages/SampleOverlappedPresenterWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="WinUIGallery.SamplePages.SampleOverlappedPresenterWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUIGallery.SamplePages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<StackPanel Spacing="5" HorizontalAlignment="Center" VerticalAlignment="Center">
<ToggleSwitch Header="HasBorder" IsOn="{x:Bind HasBorder, Mode=TwoWay}"/>
<ToggleSwitch Header="HasTitleBar" IsOn="{x:Bind HasTitleBar, Mode=TwoWay}"/>
<ToggleSwitch Header="IsAlwaysOnTop" IsOn="{x:Bind IsAlwaysOnTop, Mode=TwoWay}"/>
<ToggleSwitch Header="IsMaximizable" IsOn="{x:Bind IsMaximizable, Mode=TwoWay}"/>
<ToggleSwitch Header="IsMinimizable" IsOn="{x:Bind IsMinimizable, Mode=TwoWay}"/>
<ToggleSwitch Header="IsModal" IsOn="{x:Bind IsModal, Mode=TwoWay}"/>
<ToggleSwitch Header="IsResizable" IsOn="{x:Bind IsResizable, Mode=TwoWay}"/>

<ToggleButton Click="ToggleButton_Click" HorizontalAlignment="Center" Margin="0,20">ExtendsContentIntoTitleBar</ToggleButton>
</StackPanel>
</Window>
Loading