Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
47acf96
Initial SizerBase template commit
michael-hawker May 4, 2022
58daab2
Initial port of GridSplitter PR from Toolkit Repo
michael-hawker May 5, 2022
f25ed41
Fix XAML and add initial ContentSizer page/examples
michael-hawker May 5, 2022
560c615
Add PropertySizer Sample (tested with UWP)
michael-hawker May 5, 2022
ef1973f
Add ProtectedCursor code for WinUI 3 - NOTE CRASHES
michael-hawker May 5, 2022
b48bf86
Add workaround to WinUI issue so ProtectedCursor works for WinUI 3
michael-hawker May 6, 2022
6c66ffd
Fix issue with WASM not showing C#/XAML in root folder of sample project
michael-hawker May 6, 2022
0b6558e
Clean-up logic for UWP and WinUI 3 do deal with Cursor changing and i…
michael-hawker May 6, 2022
686e228
Add base document file to showcase common SizerBase features amongst …
michael-hawker May 6, 2022
a804ded
Update .NET SDK patch version
michael-hawker May 10, 2022
7496db3
Apply XAML Styler to new Sample pages
michael-hawker May 10, 2022
4ae14d9
Use WinAppSDK 1.0.3
michael-hawker May 10, 2022
51ca456
Add extra Uno guards for iOS and Android
michael-hawker May 10, 2022
e0d3091
Resolve last of uno guards for accessibility view and WinAppSDK ignor…
michael-hawker May 10, 2022
2146b92
Add guard around WinUI 3 ProtectedCursor property for Uno
michael-hawker May 11, 2022
1016cc1
Suppress CA1001 errors coming from Uno for DependencyObject generator
michael-hawker May 10, 2022
5d53dc1
Change RootNamespace for source projects to work around https://githu…
michael-hawker May 11, 2022
7dfb6cf
Fix mismatched types in DependencyProperty definitions (crashed on Sk…
michael-hawker May 12, 2022
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.201'
dotnet-version: '6.0.202'

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repository
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
- name: Install .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.201'
dotnet-version: '6.0.202'

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repository
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
- name: Install .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.201'
dotnet-version: '6.0.202'

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ private async Task LoadData()

return textContents;
}
catch
catch (Exception e)
{
return null;
return $"Exception Encountered Loading file '{filePath}':\n{e.Message}\n{e.StackTrace}";
}
}

Expand All @@ -214,7 +214,12 @@ private static string GetRelativePathToFileWithoutExtension(Type type)

var folderPath = typeNamespace.Replace(simpleAssemblyName, "").Trim('.').Replace('.', '/');

return $"SourceAssets/{sampleName}/samples/{simpleAssemblyName}/{folderPath}/{type.Name}";
if (folderPath.Length != 0)
{
folderPath += "/";
}

return $"SourceAssets/{sampleName}/samples/{simpleAssemblyName}/{folderPath}{type.Name}";
}
}
}
2 changes: 1 addition & 1 deletion common/Labs.MultiTarget.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@

<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == '$(UwpTargetFramework)'" Include="Microsoft.UI.Xaml" Version="2.7.0" />
<PackageReference Condition="'$(TargetFramework)' == '$(WinAppSdkTargetFramework)'" Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
<PackageReference Condition="'$(TargetFramework)' == '$(WinAppSdkTargetFramework)'" Include="Microsoft.WindowsAppSDK" Version="1.0.3" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion common/Labs.WinAppSdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.3" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.3" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(RepositoryDirectory)common\Labs.MultiTarget.props" />

<PropertyGroup>
<RootNamespace>CommunityToolkit.Labs.WinUI</RootNamespace>
<RootNamespace>CommunityToolkit.Labs.WinUI.CanvasLayoutRns</RootNamespace>
</PropertyGroup>

<PropertyGroup>
Expand Down
289 changes: 289 additions & 0 deletions labs/SizerBase/SizerBase.sln

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions labs/SizerBase/samples/SizerBase.Sample/ContentSizer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: ContentSizer
author: mhawker
description: The ContentSizer is a control which can be used to resize any element, usually its parent.
keywords: ContentSizer, SizerBase, Control, Layout, Expander
dev_langs:
- csharp
category: Controls
subcategory: Layout
---

<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/en-us/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. -->

# ContentSizer

<!-- TODO: Link docs -->
The ContentSizer is a control which can be used to resize any element, usually its parent. If you are using a `Grid`, use [GridSplitter](GridSplitter.md) instead.

# Examples

The main use-case for a ContentSizer is to create an expandable shelf for your application. This allows the `Expander` itself to remember its opening/closing sizes.

A GridSplitter would be insufficient as it would force the grid to remember the row size and maintain its position when the `Expander` collapses.

> [!SAMPLE ContentSizerTopShelfPage]

The following example shows how to use the ContentSizer to create a left-side shelf; however, this scenario can also be accomplished with a GridSplitter.

> [!SAMPLE ContentSizerLeftShelfPage]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Page x:Class="SizerBase.Sample.ContentSizerLeftShelfPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.Labs.WinUI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid MinWidth="400"
MinHeight="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<!-- Left-side 'Shelf', In this case you could also use a GridSplitter -->
<Border x:Name="SideContent"
MinWidth="200"
MaxWidth="600"
Background="DarkGreen">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center">
Side Content
</TextBlock>
</Border>
<controls:ContentSizer Grid.Column="1"
TargetControl="{x:Bind SideContent}" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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.Labs.Core.SourceGenerators;
using CommunityToolkit.Labs.Core.SourceGenerators.Attributes;

#if !WINAPPSDK
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
#else
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;
#endif


namespace SizerBase.Sample;

[ToolkitSample(id: nameof(ContentSizerLeftShelfPage), "Left-side Shelf", description: "Shows how to create an expandable shelf on the left-side of your app.")]
public sealed partial class ContentSizerLeftShelfPage : Page
{
public ContentSizerLeftShelfPage()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Page x:Class="SizerBase.Sample.ContentSizerTopShelfPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.Labs.WinUI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">

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

<!-- Bottom 'Shelf', In this case you cannot use GridSplitter as row would maintain its size when Expander gets collapsed -->
<muxc:Expander x:Name="TopExpander"
VerticalAlignment="Top"
HorizontalContentAlignment="Stretch"
ExpandDirection="Up"
Header="This is some Shelf"
IsExpanded="True">
<Grid x:Name="ExpandContent"
Height="128"
MinHeight="32"
MaxHeight="256">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="This is the expanded content"
TextWrapping="Wrap" />
</Grid>
</muxc:Expander>
<!-- We expand the inner content size here so that Expander maintains it's size properly. -->
<controls:ContentSizer Grid.Row="1"
Height="16"
VerticalAlignment="Top"
Orientation="Horizontal"
TargetControl="{x:Bind ExpandContent}"
Visibility="{x:Bind TopExpander.IsExpanded, Mode=OneWay}" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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.Labs.Core.SourceGenerators;
using CommunityToolkit.Labs.Core.SourceGenerators.Attributes;

#if !WINAPPSDK
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
#else
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;
#endif


namespace SizerBase.Sample;

[ToolkitSample(id: nameof(ContentSizerTopShelfPage), "Top Shelf", description: "Shows how to create an expandable shelf on the top of your app.")]
public sealed partial class ContentSizerTopShelfPage : Page
{
public ContentSizerTopShelfPage()
{
this.InitializeComponent();
}
}
29 changes: 29 additions & 0 deletions labs/SizerBase/samples/SizerBase.Sample/PropertySizer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: PropertySizer
author: mhawker
description: The PropertySizer is a control which can be used to manipulate the value of another double based property.
keywords: PropertySizer, SizerBase, Control, Layout, NavigationView
dev_langs:
- csharp
category: Controls
subcategory: Layout
---

<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/en-us/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. -->

# PropertySizer

<!-- TODO: Link docs -->
The PropertySizer is a control which can be used to manipulate the value of another <c>double</c> based property. For instance manipulating the <c>OpenPaneLength</c> of a <c>NavigationView</c> control. If you are using a <see cref="Grid"/>, use <see cref="GridSplitter"/> instead.

# Examples

The main use-case is for PropertySizer to allow you to manipulate the `OpenPaneLength` property of a `NavigationView` control to create a user customizable size shelf. This is handy when using NavigationView with a tree of items that represents some project or folder structure for your application.

Both GridSplitter and ContentSizer are insufficient as they would force the NavigationView to a specific size and not allow it to remember its size when it expands or collapses.

> [!SAMPLE PropertySizerNavigationViewPage]
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<Page x:Class="SizerBase.Sample.PropertySizerNavigationViewPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.Labs.WinUI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">

<muxc:NavigationView x:Name="ViewPanel"
MinHeight="300"
IsPaneOpen="True"
OpenPaneLength="300"
PaneDisplayMode="Left">
<muxc:NavigationView.AutoSuggestBox>
<AutoSuggestBox AutomationProperties.Name="Search"
QueryIcon="Find" />
</muxc:NavigationView.AutoSuggestBox>
<muxc:NavigationView.MenuItems>
<muxc:NavigationViewItem Content="Menu Item1"
Tag="SamplePage1">
<muxc:NavigationViewItem.Icon>
<SymbolIcon Symbol="Play" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem Content="Menu Item2"
Tag="SamplePage2">
<muxc:NavigationViewItem.Icon>
<SymbolIcon Symbol="Save" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem Content="Menu Item3 with Really Long Name and Such..."
Tag="SamplePage3">
<muxc:NavigationViewItem.Icon>
<SymbolIcon Symbol="Refresh" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem Content="Menu Item4"
Tag="SamplePage4">
<muxc:NavigationViewItem.Icon>
<SymbolIcon Symbol="Download" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
</muxc:NavigationView.MenuItems>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Note the use of a TwoWay binding here, this is required for this control to work. -->
<controls:PropertySizer HorizontalAlignment="Left"
Binding="{x:Bind ViewPanel.OpenPaneLength, Mode=TwoWay}"
Maximum="440"
Minimum="52"
Visibility="{x:Bind ViewPanel.IsPaneOpen, Mode=OneWay}" />
<!--In An Application, put your host frame here: <Frame Grid.Column="1"/>-->
<!-- Here we show the content as a border for a visual aid -->
<Border Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="Red"
BorderThickness="4">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{x:Bind ViewPanel.OpenPaneLength, Mode=OneWay}" />
</Border>
</Grid>
</muxc:NavigationView>
</Page>
Loading