-
Notifications
You must be signed in to change notification settings - Fork 73
Added improved default control and style examples to ProjectTemplate #167
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
Merged
Merged
Changes from 30 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
6f12714
Added improved default control and style examples to ProjectTemplate
Arlodotexe 5dfd11c
Fixed code style issues
Arlodotexe 8cfeb9d
Fixed xaml styling
Arlodotexe 46a3c7a
Fixed compiler errors
Arlodotexe b72364e
Don't throw if template part is missing
Arlodotexe a31ec63
Fixed missing compilation conditional when template is generated
Arlodotexe 8d522a5
Fixed missing compilation conditional when template is generated
Arlodotexe 6d84ee2
Removed Rns from namespaces
Arlodotexe f46651f
Use is not null instead of returning
Arlodotexe 7124bb4
Merge main
Arlodotexe 5e10461
Fixed issue where using the same property name in multiple samples wi…
Arlodotexe a47f490
Added default templated control examples
Arlodotexe 4c5859c
Merge main
Arlodotexe c4aac54
Fixed compiler error on Android
Arlodotexe 37476b4
Removed unused usings
Arlodotexe c714c3f
Removed leftover test code
Arlodotexe f81d1e8
Added TestMethod attribute back
Arlodotexe 8aeb435
Added event handling examples, extra comments
Arlodotexe 3c43d68
Use protected property for storing template part, fixed event unsubsc…
Arlodotexe 5a22427
Add missing period to code comment.
Arlodotexe 516328e
Templated control examples for x:Bind and classic binding are now com…
Arlodotexe 13d462f
Apply xaml styling missed by autoformat
Arlodotexe b0b8d59
Added missing file headers
Arlodotexe f163437
Fixed compiler errors
Arlodotexe 3893b01
Fixed more compiler errors
Arlodotexe 59e0036
Ran xaml styler
Arlodotexe f9eda93
WIP: implicit styles via Generic.xaml
Arlodotexe b4f5f26
Fixed applying default styles
Arlodotexe 41e7bb4
Fixed namespaces
Arlodotexe f793003
Ran XAML styler
Arlodotexe 0a2bf51
Ran XAML styler on specific failing files
Arlodotexe 01fc1f0
Renamed DefaultTemplatedControlStyle to DefaultProjectTemplateStyle
Arlodotexe 921f4a1
Removed ItemGroup content covered by wildcard
Arlodotexe 1e7543e
Merge branch 'main' into feature/default-project-controls
Arlodotexe 36568d4
Fixed invalid namespace
Arlodotexe 6fe0ab3
Ran XAML styler on failing files
Arlodotexe ab4ad5c
Fixed compiler warning
Arlodotexe 23085b2
Fixed unit test invoking on wrong thread
Arlodotexe 910dd57
Removed uneeded x:Name
Arlodotexe 56a898b
Replaced CustomTemplatedControlStyle with CustomProjectTemplateStyle
Arlodotexe 5d382e4
Replaced TemplatedControlSample with ProjectTemplateControlSample
Arlodotexe 6e1ca59
Removed unused test page
Arlodotexe 23002bc
Renamed DefaultTemplatedControlItemPadding to DefaultProjectTemplateI…
Arlodotexe bec9d59
Made default style keys unique between variations
Arlodotexe 377e0d7
Removed extra ItemGroups covered by wildcards
Arlodotexe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
...ample/ProjectTemplateFirstSamplePage.xaml → ....Sample/BackedTemplatedControlSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
<!-- 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="ProjectTemplate.Sample.ProjectTemplateFirstSamplePage" | ||
<Page x:Class="ProjectTemplate.Sample.BackedTemplatedControlSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:ProjectTemplate.Sample" | ||
xmlns:labs="using:CommunityToolkit.Labs.WinUI" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
<StackPanel> | ||
<TextBlock x:Name="PrimaryText" | ||
FontFamily="{x:Bind TextFontFamily, Mode=OneWay}" | ||
FontSize="{x:Bind TextSize, Mode=OneWay}" | ||
Foreground="{x:Bind TextForeground, Mode=OneWay}" | ||
Text="Add sample here." | ||
Visibility="{x:Bind IsTextVisible, Mode=OneWay}" /> | ||
|
||
<StackPanel Padding="20" | ||
Spacing="15"> | ||
<labs:ProjectTemplate_xBind FontFamily="{x:Bind TextFontFamily, Mode=OneWay}" | ||
FontSize="{x:Bind TextSize, Mode=OneWay}" | ||
Foreground="{x:Bind TextForeground, Mode=OneWay}" | ||
Visibility="{x:Bind IsTextVisible, Mode=OneWay}" /> | ||
</StackPanel> | ||
</Page> |
24 changes: 24 additions & 0 deletions
24
template/lab/samples/ProjectTemplate.Sample/BackedTemplatedControlSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ProjectTemplate.Sample; | ||
|
||
[ToolkitSampleBoolOption("IsTextVisible", "IsVisible", true)] | ||
// Single values without a colon are used for both label and value. | ||
// To provide a different label for the value, separate with a colon surrounded by a single space on both sides ("label : value"). | ||
[ToolkitSampleMultiChoiceOption("TextSize", title: "Text size", "Small : 12", "Normal : 16", "Big : 32")] | ||
[ToolkitSampleMultiChoiceOption("TextFontFamily", title: "Font family", "Segoe UI", "Arial", "Consolas")] | ||
[ToolkitSampleMultiChoiceOption("TextForeground", title: "Text foreground", | ||
"Teal : #0ddc8c", | ||
"Sand : #e7a676", | ||
"Dull green : #5d7577")] | ||
|
||
[ToolkitSample(id: nameof(BackedTemplatedControlSample), "Backed templated control", description: "A sample for showing how to create and use a templated control with a backed resource dictionary.")] | ||
public sealed partial class BackedTemplatedControlSample : Page | ||
{ | ||
public BackedTemplatedControlSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
template/lab/samples/ProjectTemplate.Sample/BackedTemplatedControlWithCustomStyleSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- 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="ProjectTemplate.Sample.BackedTemplatedControlWithCustomStyleSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:labs="using:CommunityToolkit.Labs.WinUI" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<!-- Import custom styles --> | ||
<labs:ProjectTemplateStyle_xBind /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Page.Resources> | ||
|
||
<StackPanel Padding="20" | ||
Spacing="15"> | ||
<labs:ProjectTemplate_xBind FontFamily="{x:Bind TextFontFamily, Mode=OneWay}" | ||
FontSize="{x:Bind TextSize, Mode=OneWay}" | ||
Foreground="{x:Bind TextForeground, Mode=OneWay}" | ||
Style="{StaticResource CustomTemplatedControlStyle}" | ||
Visibility="{x:Bind IsTextVisible, Mode=OneWay}" /> | ||
</StackPanel> | ||
</Page> |
24 changes: 24 additions & 0 deletions
24
...te/lab/samples/ProjectTemplate.Sample/BackedTemplatedControlWithCustomStyleSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ProjectTemplate.Sample; | ||
|
||
[ToolkitSampleBoolOption("IsTextVisible", "IsVisible", true)] | ||
// Single values without a colon are used for both label and value. | ||
// To provide a different label for the value, separate with a colon surrounded by a single space on both sides ("label : value"). | ||
[ToolkitSampleMultiChoiceOption("TextSize", title: "Text size", "Small : 12", "Normal : 16", "Big : 32")] | ||
[ToolkitSampleMultiChoiceOption("TextFontFamily", title: "Font family", "Segoe UI", "Arial", "Consolas")] | ||
[ToolkitSampleMultiChoiceOption("TextForeground", title: "Text foreground", | ||
"Teal : #0ddc8c", | ||
"Sand : #e7a676", | ||
"Dull green : #5d7577")] | ||
|
||
[ToolkitSample(id: nameof(BackedTemplatedControlWithCustomStyleSample), "Backed templated control (restyled)", description: "A sample for showing how to create and use a templated control with a backed resource dictionary and a custom style.")] | ||
public sealed partial class BackedTemplatedControlWithCustomStyleSample : Page | ||
{ | ||
public BackedTemplatedControlWithCustomStyleSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
template/lab/samples/ProjectTemplate.Sample/TemplatedControlSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- 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="ProjectTemplate.Sample.TemplatedControlSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:labs="using:CommunityToolkit.Labs.WinUI" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<StackPanel Padding="20" | ||
Spacing="15"> | ||
<labs:ProjectTemplate_ClassicBinding FontFamily="{x:Bind TextFontFamily, Mode=OneWay}" | ||
FontSize="{x:Bind TextSize, Mode=OneWay}" | ||
Foreground="{x:Bind TextForeground, Mode=OneWay}" | ||
Visibility="{x:Bind IsTextVisible, Mode=OneWay}" /> | ||
</StackPanel> | ||
</Page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
template/lab/samples/ProjectTemplate.Sample/TemplatedControlWithCustomStyleSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- 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="ProjectTemplate.Sample.TemplatedControlWithCustomStyleSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:labs="using:CommunityToolkit.Labs.WinUI" | ||
xmlns:local="using:ProjectTemplate.Sample" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<!-- Import custom styles --> | ||
<ResourceDictionary Source="ms-appx:///CommunityToolkit.Labs.WinUI.ProjectTemplate/ProjectTemplateStyle_ClassicBinding.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Page.Resources> | ||
|
||
<StackPanel Padding="20" | ||
Spacing="15"> | ||
<labs:ProjectTemplate_ClassicBinding FontFamily="{x:Bind TextFontFamily, Mode=OneWay}" | ||
FontSize="{x:Bind TextSize, Mode=OneWay}" | ||
Foreground="{x:Bind TextForeground, Mode=OneWay}" | ||
Style="{StaticResource CustomTemplatedControlStyle}" | ||
Visibility="{x:Bind IsTextVisible, Mode=OneWay}" /> | ||
</StackPanel> | ||
</Page> |
24 changes: 24 additions & 0 deletions
24
template/lab/samples/ProjectTemplate.Sample/TemplatedControlWithCustomStyleSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ProjectTemplate.Sample; | ||
|
||
[ToolkitSampleBoolOption("IsTextVisible", "IsVisible", true)] | ||
// Single values without a colon are used for both label and value. | ||
// To provide a different label for the value, separate with a colon surrounded by a single space on both sides ("label : value"). | ||
[ToolkitSampleMultiChoiceOption("TextSize", title: "Text size", "Small : 12", "Normal : 16", "Big : 32")] | ||
[ToolkitSampleMultiChoiceOption("TextFontFamily", title: "Font family", "Segoe UI", "Arial", "Consolas")] | ||
[ToolkitSampleMultiChoiceOption("TextForeground", title: "Text foreground", | ||
"Teal : #0ddc8c", | ||
"Sand : #e7a676", | ||
"Dull green : #5d7577")] | ||
|
||
[ToolkitSample(id: nameof(TemplatedControlWithCustomStyleSample), "Templated control (restyled)", description: "A sample for showing how to create a use and templated control with a custom style.")] | ||
public sealed partial class TemplatedControlWithCustomStyleSample : Page | ||
{ | ||
public TemplatedControlWithCustomStyleSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ | |
<Name>ProjectTemplate.Sample</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
</Project> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!-- 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. --> | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:labs="using:CommunityToolkit.Labs.WinUI"> | ||
|
||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Light"> | ||
<SolidColorBrush x:Key="MyBrush" Color="#000000" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Dark"> | ||
<SolidColorBrush x:Key="MyBrush" Color="{StaticResource SystemBaseMediumColor}" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="HighContrast"> | ||
<SolidColorBrush x:Key="MyBrush" Color="{ThemeResource SystemColorButtonFaceColor}" /> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
|
||
<Thickness x:Key="DefaultTemplatedControlItemPadding">4,4,4,4</Thickness> | ||
|
||
<!-- Implicitly applied default style --> | ||
<Style BasedOn="{StaticResource DefaultTemplatedControlStyle}" TargetType="labs:ProjectTemplate_ClassicBinding" /> | ||
|
||
<Style x:Key="DefaultTemplatedControlStyle" TargetType="labs:ProjectTemplate_ClassicBinding"> | ||
<Style.Setters> | ||
<Setter Property="MyProperty" Value="This property has been overriden by the style template" /> | ||
<Setter Property="ItemPadding" Value="{StaticResource DefaultTemplatedControlItemPadding}" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="labs:ProjectTemplate_ClassicBinding"> | ||
<Grid Padding="{TemplateBinding ItemPadding}"> | ||
<StackPanel Spacing="20"> | ||
<TextBlock | ||
x:Name="PART_HelloWorld" | ||
Foreground="{ThemeResource MyBrush}" | ||
Text="Hello world!" /> | ||
|
||
<TextBlock Text="{TemplateBinding MyProperty}" /> | ||
<TextBlock Text="{Binding MyProperty, RelativeSource={RelativeSource Mode=TemplatedParent}}" Visibility="Collapsed" /> | ||
</StackPanel> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style.Setters> | ||
</Style> | ||
|
||
<!-- Minimal, custom style --> | ||
<Style | ||
x:Key="CustomTemplatedControlStyle" | ||
BasedOn="{StaticResource DefaultTemplatedControlStyle}" | ||
TargetType="labs:ProjectTemplate_ClassicBinding"> | ||
<Style.Setters> | ||
<Setter Property="MyProperty" Value="This property has been overriden by a custom style!" /> | ||
<Setter Property="ItemPadding" Value="25" /> | ||
</Style.Setters> | ||
</Style> | ||
|
||
</ResourceDictionary> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.