diff --git a/Microsoft.Toolkit.Uwp.SampleApp/App.xaml b/Microsoft.Toolkit.Uwp.SampleApp/App.xaml
index f7b74b15f8d..37bc22cada3 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/App.xaml
+++ b/Microsoft.Toolkit.Uwp.SampleApp/App.xaml
@@ -4,25 +4,25 @@
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
RequiresPointerMode="Auto">
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Controls/CodeRenderer.xaml b/Microsoft.Toolkit.Uwp.SampleApp/Controls/CodeRenderer.xaml
index 07dbe5a069d..0b9a08e9a16 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/Controls/CodeRenderer.xaml
+++ b/Microsoft.Toolkit.Uwp.SampleApp/Controls/CodeRenderer.xaml
@@ -1,8 +1,7 @@
-
+
+ TargetType="HyperlinkButton">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+ Height="80"
+ ui:VisualExtensions.CenterPoint="40,60,0">
-
+ VerticalContentAlignment="Stretch"
+ ui:VisualExtensions.Opacity="0"
+ BlurRadius="30"
+ OffsetY="3"
+ ShadowOpacity="0.6"
+ Visibility="Collapsed">
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
+
-
+
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
@@ -851,8 +886,15 @@
-
-
+
+
@@ -860,7 +902,8 @@
-
+
@@ -872,10 +915,41 @@
-
-
-
-
+
+
+
+
@@ -887,478 +961,110 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Styles/GithubIcon.xaml b/Microsoft.Toolkit.Uwp.SampleApp/Styles/GithubIcon.xaml
index ea3ceee5c78..c1968130be5 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/Styles/GithubIcon.xaml
+++ b/Microsoft.Toolkit.Uwp.SampleApp/Styles/GithubIcon.xaml
@@ -1,8 +1,7 @@
-
+
-
+
M21.7999992370605,0L19.220495223999,0.26007080078125 16.81787109375,1.00595712661743 14.6436157226563,2.18616962432861 12.7492189407349,3.74921894073486 11.1861696243286,5.64361572265625 10.0059566497803,7.81787109375 9.26007080078125,10.2204961776733 9,12.8000001907349 9.65248012542725,16.8459720611572 11.4694375991821,20.3591785430908 14.2401514053345,23.1291217803955 17.7539005279541,24.9453010559082 18.4305686950684,24.8080005645752 18.6273498535156,24.3296756744385 18.6207065582275,23.4247951507568 18.609375,21.9468746185303 16.4340572357178,22.0373229980469 15.1187467575073,21.4822216033936 14.4708204269409,20.7821025848389 14.2976503372192,20.4375 13.8297338485718,19.5214366912842 13.3685493469238,18.947265625 12.8765497207642,18.5656261444092 12.3995819091797,18.1091804504395 12.4844465255737,17.87890625 12.7874250411987,17.7974605560303 12.9647998809814,17.7875003814697 13.8134965896606,18.0311241149902 14.4276065826416,18.4802703857422 14.8007507324219,18.9127178192139 14.926549911499,19.1062507629395 15.8880548477173,20.1437015533447 16.9443283081055,20.494140625 17.9229640960693,20.416259765625 18.6515502929688,20.1687507629395 18.9645938873291,19.1242198944092 19.4640502929688,18.4593753814697 17.3543262481689,18.0241260528564 15.4833002090454,17.014066696167 14.1450357437134,15.1450166702271 13.6336002349854,12.1328001022339 13.9853601455688,10.2268438339233 14.9500007629395,8.69764995574951 14.7027282714844,7.54188776016235 14.7441072463989,6.53565359115601 15.0765495300293,5.30859994888306 15.2825078964233,5.28076791763306 15.9191312789917,5.34375619888306 17.0145378112793,5.71729135513306 18.596851348877,6.62109994888306 21.799976348877,6.19062519073486 25.004674911499,6.62265014648438 26.5845413208008,5.71818733215332 27.6791000366211,5.34472513198853 28.315746307373,5.28210020065308 28.5218753814697,5.31015014648438 28.8556652069092,6.53784370422363 28.8976573944092,7.5438346862793 28.6499996185303,8.69764995574951 29.6154251098633,10.2268533706665 29.9656257629395,12.1328001022339 29.453296661377,15.1497011184692 28.1123065948486,17.0164012908936 26.2366523742676,18.020601272583 24.120325088501,18.4500007629395 24.7275562286377,19.3355484008789 24.9890747070313,20.8187503814697 24.9804744720459,23.0584030151367 24.9718742370605,24.3312511444092 25.1693305969238,24.8128852844238 25.8531246185303,24.9453010559082 29.3641395568848,23.1273632049561 32.1326217651367,20.3568344116211 33.948070526123,16.8442134857178 34.5999984741211,12.8000001907349 34.3399276733398,10.2204961776733 33.5940399169922,7.81787109375 32.4138298034668,5.64361572265625 30.8507804870605,3.74921894073486 28.9563827514648,2.18616962432861 26.7821273803711,1.00595712661743 24.3795032501221,0.26007080078125 21.7999992370605,0z
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Styles/Themes.xaml b/Microsoft.Toolkit.Uwp.SampleApp/Styles/Themes.xaml
index 0fa938e4864..c3bc16e4dbd 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/Styles/Themes.xaml
+++ b/Microsoft.Toolkit.Uwp.SampleApp/Styles/Themes.xaml
@@ -4,7 +4,8 @@
#3750D1
-
+
#FFFFFFFF
@@ -12,15 +13,16 @@
#FF0078D7
#FFFF0000
-
+
#FFDDDDDD
-
+
-
+
White
Black
#FF333333
@@ -30,32 +32,32 @@
#FFF0F0F0
#FFEEEEEE
-
+
+ Color="{StaticResource Brand-Color}" />
-
+ Color="#CC191919" />
+
+ Color="{ThemeResource Grey-01}" />
+ Color="{ThemeResource Grey-02}" />
+ Color="{ThemeResource Grey-03}" />
+ Color="{ThemeResource Grey-04}" />
+ Color="{ThemeResource Grey-05}" />
+ Color="{StaticResource White}" />
+ Color="Black" />
+ Color="{StaticResource Blue-01}" />
-
-
+
+
-
+
Black
White
#FFF0F0F0
@@ -107,32 +111,32 @@
#FF333333
#FF222222
-
+
+ Color="{StaticResource Brand-Color}" />
-
+ Color="#CCFFFFFF" />
+
+ Color="{ThemeResource Grey-01}" />
+ Color="{ThemeResource Grey-02}" />
+ Color="{ThemeResource Grey-03}" />
+ Color="{ThemeResource Grey-04}" />
+ Color="{ThemeResource Grey-05}" />
+ Color="{StaticResource Black}" />
+ Color="White" />
+ Color="{StaticResource Blue-01}" />
-
-
+
+
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/landingPageLinks.json b/Microsoft.Toolkit.Uwp.SampleApp/landingPageLinks.json
index da4679187e2..05acdfa32a3 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/landingPageLinks.json
+++ b/Microsoft.Toolkit.Uwp.SampleApp/landingPageLinks.json
@@ -1,6 +1,6 @@
{
"new-section-title": "What's New",
- "new-samples": [ "TokenizingTextBox", "PipelineBrush", "WrapLayout", "IsNullOrEmptyStateTrigger", "High Performance APIs" ],
+ "new-samples": [ "MVVM Toolkit", "EffectAnimations", "TabbedCommandBar", "ColorPicker", "ColorPickerButton", "SwitchPresenter" ],
"resources": [
{
"title": "Toolkit",
@@ -28,6 +28,10 @@
{
"title": "UWP Community Discord",
"url": "https://discord.gg/zBA5aCn"
+ },
+ {
+ "title": "Contribution Wiki",
+ "url": "https://aka.ms/wct/wiki"
}
]
},
@@ -82,11 +86,11 @@
"links": [
{
"title": "Version",
- "url": "http://aka.ms/uwptoolkit"
+ "url": "http://aka.ms/windowstoolkit"
},
{
"title": "ColorCode-Universal (Dependency)",
- "url": "https://github.com/WilliamABradley/ColorCode-Universal"
+ "url": "https://github.com/windows-toolkit/ColorCode-Universal"
},
{
"title": "Monaco Editor UWP (Dependency)",
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/SwitchPresenter/SwitchPresenter.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/SwitchPresenter/SwitchPresenter.cs
index c977b1b3681..16a99d19a52 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/SwitchPresenter/SwitchPresenter.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/SwitchPresenter/SwitchPresenter.cs
@@ -46,7 +46,7 @@ public CaseCollection SwitchCases
/// Indicates the property.
///
public static readonly DependencyProperty SwitchCasesProperty =
- DependencyProperty.Register(nameof(SwitchCases), typeof(CaseCollection), typeof(SwitchPresenter), new PropertyMetadata(null));
+ DependencyProperty.Register(nameof(SwitchCases), typeof(CaseCollection), typeof(SwitchPresenter), new PropertyMetadata(null, OnSwitchCasesPropertyChanged));
///
/// Gets or sets a value indicating the value to compare all cases against. When this value is bound to and changes, the presenter will automatically evaluate cases and select the new appropriate content from the switch.
@@ -81,9 +81,19 @@ public Type TargetType
private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// When our Switch's expression changes, re-evaluate.
- var xswitch = (SwitchPresenter)d;
+ if (d is SwitchPresenter xswitch)
+ {
+ xswitch.EvaluateCases();
+ }
+ }
- xswitch.EvaluateCases();
+ private static void OnSwitchCasesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ // If our collection somehow changes, we should re-evaluate.
+ if (d is SwitchPresenter xswitch)
+ {
+ xswitch.EvaluateCases();
+ }
}
///
@@ -92,6 +102,14 @@ private static void OnValuePropertyChanged(DependencyObject d, DependencyPropert
public SwitchPresenter()
{
this.SwitchCases = new CaseCollection();
+
+ Loaded += this.SwitchPresenter_Loaded;
+ }
+
+ private void SwitchPresenter_Loaded(object sender, RoutedEventArgs e)
+ {
+ // In case we're in a template, we may have loaded cases later.
+ EvaluateCases();
}
///
@@ -104,8 +122,20 @@ protected override void OnApplyTemplate()
private void EvaluateCases()
{
- if (CurrentCase != null &&
- CurrentCase.Value != null &&
+ if (SwitchCases == null ||
+ SwitchCases.Count == 0)
+ {
+ // If we have no cases, then we can't match anything.
+ if (CurrentCase != null)
+ {
+ // Only bother clearing our actual content if we had something before.
+ Content = null;
+ CurrentCase = null;
+ }
+
+ return;
+ }
+ else if (CurrentCase?.Value != null &&
CurrentCase.Value.Equals(Value))
{
// If the current case we're on already matches our current value,
@@ -134,7 +164,7 @@ private void EvaluateCases()
if (newcase == null && xdefault != null)
{
- // Inject default if we found one.
+ // Inject default if we found one without matching anything
newcase = xdefault;
}
diff --git a/Microsoft.Toolkit.Uwp/Helpers/PackageVersionHelper.cs b/Microsoft.Toolkit.Uwp/Helpers/PackageVersionHelper.cs
index db05533a07c..fcf71a4ac8a 100644
--- a/Microsoft.Toolkit.Uwp/Helpers/PackageVersionHelper.cs
+++ b/Microsoft.Toolkit.Uwp/Helpers/PackageVersionHelper.cs
@@ -2,6 +2,7 @@
// 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;
using Windows.ApplicationModel;
namespace Microsoft.Toolkit.Uwp.Helpers
@@ -15,10 +16,28 @@ public static class PackageVersionHelper
/// Returns a string representation of a version with the format 'Major.Minor.Build.Revision'.
///
/// The to convert to a string
+ /// The number of version numbers to return, default is 4 for the full version number.
/// Version string of the format 'Major.Minor.Build.Revision'
- public static string ToFormattedString(this PackageVersion packageVersion)
+ ///
+ /// Package.Current.Id.Version.ToFormattedString(2); // Returns "7.0" for instance.
+ ///
+ public static string ToFormattedString(this PackageVersion packageVersion, int significance = 4)
{
- return $"{packageVersion.Major}.{packageVersion.Minor}.{packageVersion.Build}.{packageVersion.Revision}";
+ switch (significance)
+ {
+ case 4:
+ return $"{packageVersion.Major}.{packageVersion.Minor}.{packageVersion.Build}.{packageVersion.Revision}";
+ case 3:
+ return $"{packageVersion.Major}.{packageVersion.Minor}.{packageVersion.Build}";
+ case 2:
+ return $"{packageVersion.Major}.{packageVersion.Minor}";
+ case 1:
+ return $"{packageVersion.Major}";
+ }
+
+ static string ThrowArgumentOutOfRangeException() => throw new ArgumentOutOfRangeException(nameof(significance), "Value must be a value 1 through 4.");
+
+ return ThrowArgumentOutOfRangeException();
}
///