Skip to content
Closed
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
3 changes: 3 additions & 0 deletions components/TitleBar/OpenSolution.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

powershell ..\..\tooling\ProjectHeads\GenerateSingleSampleHeads.ps1 -componentPath %CD% %*
Binary file added components/TitleBar/samples/Assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions components/TitleBar/samples/BlankPage1.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Page x:Class="TitleBarExperiment.Samples.BlankPage1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:TitleBarExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<controls:TitleBar x:Name="appTitleBar"
Title="Toolkit Labs Gallery"
AutoConfigureCustomTitleBar="True"
DisplayMode="Tall"
IsBackButtonVisible="True"
IsPaneButtonVisible="True"
Subtitle=" Preview">
<!--<controls:TitleBar.Icon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="/Assets/icon.png" />
</controls:TitleBar.Icon>-->
<controls:TitleBar.Content>

<AutoSuggestBox />
</controls:TitleBar.Content>
<controls:TitleBar.Footer>
<Button Content="Click" />
</controls:TitleBar.Footer>
</controls:TitleBar>
<muxc:NavigationView Grid.Row="1">
<muxc:NavigationView.MenuItems>
<muxc:NavigationViewItem Content="Test1" />
<muxc:NavigationViewItem Content="Test2" />
</muxc:NavigationView.MenuItems>
</muxc:NavigationView>
</Grid>
</Page>
24 changes: 24 additions & 0 deletions components/TitleBar/samples/BlankPage1.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace TitleBarExperiment.Samples;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class BlankPage1 : Page
{
#if WINAPPSDK
public BlankPage1(Window window)
{
this.InitializeComponent();
appTitleBar.Window = window;
}
#else
public BlankPage1()
{
this.InitializeComponent();
Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(this, true);
}
#endif
}
31 changes: 31 additions & 0 deletions components/TitleBar/samples/Dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.

MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.

For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For UWP / WinAppSDK / Uno packages, place the package references here.
-->
<Project>
<!-- WinUI 2 / UWP -->
<ItemGroup Condition="'$(IsUwp)' == 'true'">
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 2 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
</ItemGroup>

<!-- WinUI 3 / WinAppSdk -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 3 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions components/TitleBar/samples/TitleBar.Samples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<ToolkitComponentName>TitleBar</ToolkitComponentName>
</PropertyGroup>

<!-- Sets this up as a toolkit component's sample project -->
<Import Project="$(ToolingDirectory)\ToolkitComponent.SampleProject.props" />
<ItemGroup>
<None Remove="Assets\icon.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\icon.png" />
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions components/TitleBar/samples/TitleBar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: TitleBar
author: niels9001
description: TODO: Your experiment's description here
keywords: TitleBar, Control, Layout
dev_langs:
- csharp
category: Controls
subcategory: Layout
discussion-id: 0
issue-id: 0
icon: assets/icon.png
---

<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/contribute/markdown-reference -->
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->

<!-- Be sure to update the discussion/issue numbers above with your Labs discussion/issue id numbers in order for UI links to them from the sample app to work. -->

# TitleBar

TODO: Fill in information about this experiment and how to get started here...

## Custom Control

You can inherit from an existing component as well, like `Panel`, this example shows a control without a
XAML Style that will be more light-weight to consume by an app developer:

> [!Sample TitleBarCustomSample]

35 changes: 35 additions & 0 deletions components/TitleBar/samples/TitleBarCustomSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="TitleBarExperiment.Samples.TitleBarCustomSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:TitleBarExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid>
<!--<controls:TitleBar x:Name="appTitleBar"
Title="Toolkit Labs Gallery"
DisplayMode="Tall"
IsBackButtonVisible="True"
AutoConfigureCustomTitleBar="False"
IsPaneButtonVisible="True"
Subtitle=" Preview">
<controls:TitleBar.Icon>
<BitmapIcon ShowAsMonochrome="False"
UriSource="ms-appx:///Assets/icon.png" />
</controls:TitleBar.Icon>
<controls:TitleBar.Content>

<AutoSuggestBox />
</controls:TitleBar.Content>
<controls:TitleBar.Footer>
<Button Content="Click" />
</controls:TitleBar.Footer>
</controls:TitleBar>-->

<Button Click="Button_Click"
Content="Open new window" />
</Grid>
</Page>
64 changes: 64 additions & 0 deletions components/TitleBar/samples/TitleBarCustomSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using CommunityToolkit.WinUI.Controls;
#if WINDOWS_UWP
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.WindowManagement;
using Windows.UI.Xaml.Hosting;
#endif
namespace TitleBarExperiment.Samples;

/// <summary>
/// An example sample page of a custom control inheriting from Panel.
/// </summary>
[ToolkitSampleTextOption("TitleText", "This is a title", Title = "Input the text")]
[ToolkitSampleMultiChoiceOption("LayoutOrientation", "Horizontal", "Vertical", Title = "Orientation")]

[ToolkitSample(id: nameof(TitleBarCustomSample), "Custom control", description: $"A sample for showing how to create and use a {nameof(TitleBar)} custom control.")]
public sealed partial class TitleBarCustomSample : Page
{
public TitleBarCustomSample()
{
this.InitializeComponent();
}

// TODO: See https://github.com/CommunityToolkit/Labs-Windows/issues/149
public static Orientation ConvertStringToOrientation(string orientation) => orientation switch
{
"Vertical" => Orientation.Vertical,
"Horizontal" => Orientation.Horizontal,
_ => throw new System.NotImplementedException(),
};

private async void Button_Click(object sender, RoutedEventArgs e)
{
#if WINDOWS_UWP
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame frame = new Frame();
frame.Navigate(typeof(BlankPage1), null);
Window.Current.Content = frame;
// You have to activate the window in order to show it later.
Window.Current.Activate();

newViewId = ApplicationView.GetForCurrentView().Id;
});

bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
#endif
#if WINAPPSDK
Window newWindow = new Window
{
SystemBackdrop = new MicaBackdrop()
};
newWindow.Content = new BlankPage1(newWindow);
newWindow.Activate();
#endif
}
}
13 changes: 13 additions & 0 deletions components/TitleBar/src/AdditionalAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.CompilerServices;

// These `InternalsVisibleTo` calls are intended to make it easier for
// for any internal code to be testable in all the different test projects
// used with the Labs infrastructure.
[assembly: InternalsVisibleTo("TitleBar.Tests.Uwp")]
[assembly: InternalsVisibleTo("TitleBar.Tests.WinAppSdk")]
[assembly: InternalsVisibleTo("CommunityToolkit.Tests.Uwp")]
[assembly: InternalsVisibleTo("CommunityToolkit.Tests.WinAppSdk")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<ToolkitComponentName>TitleBar</ToolkitComponentName>
<Description>This package contains TitleBar.</Description>
<Version>0.0.1</Version>

<!-- Rns suffix is required for namespaces shared across projects. See https://github.com/CommunityToolkit/Labs-Windows/issues/152 -->
<RootNamespace>CommunityToolkit.WinUI.Controls.TitleBarRns</RootNamespace>
</PropertyGroup>

<!-- Sets this up as a toolkit component's source project -->
<Import Project="$(ToolingDirectory)\ToolkitComponent.SourceProject.props" />
</Project>
31 changes: 31 additions & 0 deletions components/TitleBar/src/Dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.

MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.

For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For UWP / WinAppSDK / Uno packages, place the package references here.
-->
<Project>
<!-- WinUI 2 / UWP -->
<ItemGroup Condition="'$(IsUwp)' == 'true'">
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 2 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
</ItemGroup>

<!-- WinUI 3 / WinAppSdk -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 3 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions components/TitleBar/src/MultiTarget.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<!--
MultiTarget is a custom property that indicates which target a project is designed to be built for / run on.
Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages.
-->
<MultiTarget>uwp;wasdk;wpf;wasm;linuxgtk;macos;ios;android;</MultiTarget>
</PropertyGroup>
</Project>
9 changes: 9 additions & 0 deletions components/TitleBar/src/Themes/Generic.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.TitleBar/TitleBar.xaml" />
</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>
Loading