Skip to content

Commit a2ed6aa

Browse files
author
msftbot[bot]
authored
Sample app updates for 7.0 (#3824)
## Fixes lots Smorgasbord of changes found or related to updating the Sample App for 7.0 shipping. - Fixes an issue with SwitchPresenter causing ColorPicker to break (Loading order for evaluating cases) - Fixes an issue on About page displaying preview version notes - Updates the Landing Page Links - Adds MVVM Toolkit Docs - Adds Wiki Link - Cleans up some XAML only samples - Applies XAML Styler ## TODO - [x] Fix Home Button not working - [x] Fix new short URLs for docs not having https://docs.microsoft.com/ to add pre-cursor - [x] Should pin github urls to v7.0.0 in release mode, kind of like what we do for docs??? - [x] Update rest of doc links - [x] Update paths in CodeUrl - [x] Update paths to docs - [x] Check animation sample links - [x] Add Animation's sample Image - [x] Graph Controls Docs at least (samples on ice still) - [ ] Build sample app in release mode for release
2 parents af7297a + 5c190b2 commit a2ed6aa

37 files changed

+909
-1404
lines changed

Microsoft.Toolkit.Uwp.SampleApp/App.xaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
55
RequiresPointerMode="Auto">
66

7-
<Application.Resources>
8-
<ResourceDictionary>
9-
<!-- Color Resources -->
10-
<ResourceDictionary.MergedDictionaries>
11-
<ResourceDictionary Source="ms-appx:///Styles/Themes.xaml" />
12-
<ResourceDictionary Source="ms-appx:///Styles/Generic.xaml" />
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<!-- Color Resources -->
10+
<ResourceDictionary.MergedDictionaries>
11+
<ResourceDictionary Source="ms-appx:///Styles/Themes.xaml" />
12+
<ResourceDictionary Source="ms-appx:///Styles/Generic.xaml" />
1313

14-
<!-- WinUI -->
15-
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
16-
</ResourceDictionary.MergedDictionaries>
14+
<!-- WinUI -->
15+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
16+
</ResourceDictionary.MergedDictionaries>
1717

18-
<!-- Converters -->
19-
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
18+
<!-- Converters -->
19+
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
2020

21-
<converters:EmptyStringToObjectConverter x:Key="EmptyStringToObject"
22-
EmptyValue="Collapsed"
23-
NotEmptyValue="Visible" />
21+
<converters:EmptyStringToObjectConverter x:Key="EmptyStringToObject"
22+
EmptyValue="Collapsed"
23+
NotEmptyValue="Visible" />
2424

25-
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
26-
</ResourceDictionary>
27-
</Application.Resources>
25+
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
26+
</ResourceDictionary>
27+
</Application.Resources>
2828
</Application>

Microsoft.Toolkit.Uwp.SampleApp/Controls/CodeRenderer.xaml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<ResourceDictionary
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:controls="using:Microsoft.Toolkit.Uwp.SampleApp.Controls"
5-
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Controls">
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:controls="using:Microsoft.Toolkit.Uwp.SampleApp.Controls"
4+
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Controls">
65

76
<Style TargetType="controls:CodeRenderer">
87
<Setter Property="Template">
@@ -14,25 +13,24 @@
1413
<RowDefinition Height="Auto" />
1514
</Grid.RowDefinitions>
1615
<Grid x:Name="Container"
17-
Grid.RowSpan="2"
18-
Opacity="0" />
19-
<ScrollViewer
20-
Grid.Row="0"
21-
HorizontalScrollMode="Auto"
22-
HorizontalScrollBarVisibility="Auto">
16+
Grid.RowSpan="2"
17+
Opacity="0" />
18+
<ScrollViewer Grid.Row="0"
19+
HorizontalScrollBarVisibility="Auto"
20+
HorizontalScrollMode="Auto">
2321
<RichTextBlock Name="codeView"
24-
FontFamily="Consolas"
25-
Padding="10" />
22+
Padding="10"
23+
FontFamily="Consolas" />
2624
</ScrollViewer>
2725
<StackPanel Grid.Row="1"
28-
HorizontalAlignment="Center"
29-
Orientation="Horizontal">
26+
HorizontalAlignment="Center"
27+
Orientation="Horizontal">
3028
<Button x:Name="CopyButton"
31-
Margin="5"
32-
Content="Copy" />
29+
Margin="5"
30+
Content="Copy" />
3331
<Button x:Name="PrintButton"
34-
Margin="5"
35-
Content="Print" />
32+
Margin="5"
33+
Content="Print" />
3634
</StackPanel>
3735
</Grid>
3836
</ControlTemplate>

Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@
272272
<Content Include="Icons\More.png" />
273273
<Content Include="Icons\Notifications.png" />
274274
<Content Include="Icons\Services.png" />
275+
<Content Include="SamplePages\Animations\Effects\EffectAnimations.png">
276+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
277+
</Content>
278+
<Content Include="SamplePages\Graph\LoginButton.png" />
279+
<Content Include="SamplePages\Graph\PeoplePicker.png" />
280+
<Content Include="SamplePages\Graph\PersonView.png" />
275281
<Content Include="SamplePages\Primitives\SwitchPresenter.png" />
276282
<Content Include="SamplePages\TabbedCommandBar\TabbedCommandBar.png" />
277283
<Content Include="SamplePages\Animations\Effects\FadeBehavior.png" />
@@ -490,12 +496,6 @@
490496
<DependentUpon>AutoFocusBehaviorPage.xaml</DependentUpon>
491497
</Compile>
492498
<Compile Include="SamplePages\CanvasPathGeometry\GeometryStreamReader.cs" />
493-
<Compile Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml.cs">
494-
<DependentUpon>ColorPickerButtonPage.xaml</DependentUpon>
495-
</Compile>
496-
<Compile Include="SamplePages\ColorPicker\ColorPickerPage.xaml.cs">
497-
<DependentUpon>ColorPickerPage.xaml</DependentUpon>
498-
</Compile>
499499
<Compile Include="SamplePages\EnumValuesExtension\Animal.cs" />
500500
<Compile Include="SamplePages\EnumValuesExtension\AnimalToColorConverter.xaml.cs" />
501501
<Compile Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml.cs">
@@ -619,6 +619,9 @@
619619
<Content Include="SamplePages\VisualEffectFactory\VisualEffectFactory.bind" />
620620
<Content Include="SamplePages\Animations\Activities\InvokeActionsActivityCode.bind" />
621621
<Content Include="SamplePages\Animations\Activities\StartAnimationActivityCode.bind" />
622+
<Content Include="SamplePages\Graph\LoginButtonXaml.bind" />
623+
<Content Include="SamplePages\Graph\PeoplePickerXaml.bind" />
624+
<Content Include="SamplePages\Graph\PersonViewXaml.bind" />
622625
</ItemGroup>
623626
<ItemGroup>
624627
<Compile Include="App.xaml.cs">
@@ -900,9 +903,6 @@
900903
<Compile Include="SamplePages\RadialGauge\RadialGaugePage.xaml.cs">
901904
<DependentUpon>RadialGaugePage.xaml</DependentUpon>
902905
</Compile>
903-
<Compile Include="SamplePages\RangeSelector\RangeSelectorPage.xaml.cs">
904-
<DependentUpon>RangeSelectorPage.xaml</DependentUpon>
905-
</Compile>
906906
<Compile Include="SamplePages\WrapPanel\WrapPanelPage.xaml.cs">
907907
<DependentUpon>WrapPanelPage.xaml</DependentUpon>
908908
</Compile>
@@ -956,14 +956,6 @@
956956
<SubType>Designer</SubType>
957957
<Generator>MSBuild:Compile</Generator>
958958
</Page>
959-
<Page Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml">
960-
<Generator>MSBuild:Compile</Generator>
961-
<SubType>Designer</SubType>
962-
</Page>
963-
<Page Include="SamplePages\ColorPicker\ColorPickerPage.xaml">
964-
<Generator>MSBuild:Compile</Generator>
965-
<SubType>Designer</SubType>
966-
</Page>
967959
<Page Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml">
968960
<Generator>MSBuild:Compile</Generator>
969961
<SubType>Designer</SubType>
@@ -1349,10 +1341,6 @@
13491341
<Generator>MSBuild:Compile</Generator>
13501342
<SubType>Designer</SubType>
13511343
</Page>
1352-
<Page Include="SamplePages\RangeSelector\RangeSelectorPage.xaml">
1353-
<Generator>MSBuild:Compile</Generator>
1354-
<SubType>Designer</SubType>
1355-
</Page>
13561344
<Page Include="SamplePages\WrapLayout\WrapLayoutPage.xaml">
13571345
<SubType>Designer</SubType>
13581346
<Generator>MSBuild:Compile</Generator>

Microsoft.Toolkit.Uwp.SampleApp/Models/GitHubRelease.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class GitHubRelease
2121
[JsonPropertyName("name")]
2222
public string Name { get; set; }
2323

24-
public string FullName => $"Version {Name.Replace("v", string.Empty)} notes";
24+
public string FullName => $"Version {Name.Substring(1)} notes"; // Skip the initial 'v' we put at the front. If we replace all 'v's then we hit 'preview'.
2525

2626
[JsonPropertyName("draft")]
2727
public bool IsDraft { get; set; }

Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using Microsoft.Toolkit.Uwp.UI.Controls;
2828
using Microsoft.Toolkit.Uwp.UI.Media;
2929
using Microsoft.UI.Xaml;
30+
using Windows.ApplicationModel;
3031
using Windows.Foundation.Metadata;
3132
using Windows.Storage;
3233
using Windows.Storage.Streams;
@@ -71,7 +72,6 @@ public static async void EnsureCacheLatest()
7172
}
7273

7374
private string _cachedDocumentation = string.Empty;
74-
private string _cachedPath = string.Empty;
7575

7676
internal static async Task<Sample> FindAsync(string category, string name)
7777
{
@@ -118,7 +118,7 @@ public string CodeUrl
118118
#if DEBUG
119119
_codeUrl = value;
120120
#else
121-
var regex = new Regex("^https://github.com/Microsoft/WindowsCommunityToolkit/(tree|blob)/(?<branch>.+?)/(?<path>.*)");
121+
var regex = new Regex("^https://github.com/windows-toolkit/WindowsCommunityToolkit/(tree|blob)/(?<branch>.+?)/(?<path>.*)");
122122
var docMatch = regex.Match(value);
123123

124124
var branch = string.Empty;
@@ -135,7 +135,8 @@ public string CodeUrl
135135
}
136136
else
137137
{
138-
_codeUrl = $"https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/{path}";
138+
var packageVersion = Package.Current.Id.Version.ToFormattedString(3);
139+
_codeUrl = $"https://github.com/Microsoft/WindowsCommunityToolkit/tree/rel/{packageVersion}/{path}";
139140
}
140141
#endif
141142
}
@@ -149,8 +150,21 @@ public string CodeUrl
149150

150151
public string XamlCode { get; private set; }
151152

153+
/// <summary>
154+
/// Gets or sets the path set in the samples.json pointing to the doc for the sample.
155+
/// </summary>
152156
public string DocumentationUrl { get; set; }
153157

158+
/// <summary>
159+
/// Gets or sets the absolute local doc path for cached file in app.
160+
/// </summary>
161+
public string LocalDocumentationFilePath { get; set; }
162+
163+
/// <summary>
164+
/// Gets or sets the base path segment to the current document location.
165+
/// </summary>
166+
public string RemoteDocumentationPath { get; set; }
167+
154168
public string Icon { get; set; }
155169

156170
public string BadgeUpdateVersionRequired { get; set; }
@@ -191,32 +205,29 @@ public async Task<string> GetCSharpSourceAsync()
191205
}
192206
}
193207

194-
#pragma warning disable SA1009 // Doesn't like ValueTuples.
195-
public async Task<(string contents, string path)> GetDocumentationAsync()
196-
#pragma warning restore SA1009 // Doesn't like ValueTuples.
208+
public async Task<string> GetDocumentationAsync()
197209
{
198210
if (!string.IsNullOrWhiteSpace(_cachedDocumentation))
199211
{
200-
return (_cachedDocumentation, _cachedPath);
212+
return _cachedDocumentation;
201213
}
202214

203215
var filepath = string.Empty;
204216
var filename = string.Empty;
205-
var localPath = string.Empty;
217+
LocalDocumentationFilePath = string.Empty;
206218

207219
var docRegex = new Regex("^" + _docsOnlineRoot + "(?<branch>.+?)/docs/(?<file>.+)");
208220
var docMatch = docRegex.Match(DocumentationUrl);
209221
if (docMatch.Success)
210222
{
211223
filepath = docMatch.Groups["file"].Value;
212-
filename = Path.GetFileName(filepath);
213-
localPath = $"ms-appx:///docs/{Path.GetDirectoryName(filepath)}/";
224+
filename = Path.GetFileName(RemoteDocumentationPath);
225+
RemoteDocumentationPath = Path.GetDirectoryName(filepath);
226+
LocalDocumentationFilePath = $"ms-appx:///docs/{RemoteDocumentationPath}/";
214227
}
215228

216229
#if !DEBUG // use the docs repo in release mode
217-
string modifiedDocumentationUrl = $"{_docsOnlineRoot}master/docs/{filepath}";
218-
219-
_cachedPath = modifiedDocumentationUrl.Replace(filename, string.Empty);
230+
string modifiedDocumentationUrl = $"{_docsOnlineRoot}live/docs/{filepath}";
220231

221232
// Read from Cache if available.
222233
try
@@ -264,15 +275,14 @@ public async Task<string> GetCSharpSourceAsync()
264275
{
265276
var result = await localDocsStream.ReadTextAsync(Encoding.UTF8);
266277
_cachedDocumentation = ProcessDocs(result);
267-
_cachedPath = localPath;
268278
}
269279
}
270280
catch (Exception)
271281
{
272282
}
273283
}
274284

275-
return (_cachedDocumentation, _cachedPath);
285+
return _cachedDocumentation;
276286
}
277287

278288
/// <summary>
@@ -661,7 +671,7 @@ private static async Task<string> GetDocsSHA()
661671
{
662672
try
663673
{
664-
var branchEndpoint = "https://api.github.com/repos/microsoftdocs/uwpcommunitytoolkitdocs/git/refs/heads/live";
674+
var branchEndpoint = "https://api.github.com/repos/microsoftdocs/windowscommunitytoolkitdocs/git/refs/heads/live";
665675

666676
var request = new HttpRequestMessage(HttpMethod.Get, branchEndpoint);
667677
request.Headers.Add("User-Agent", "Windows Community Toolkit Sample App");

Microsoft.Toolkit.Uwp.SampleApp/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap mp uap3">
3-
<Identity Name="52b9212c-97a9-4639-9426-3e1ea9c1569e" Publisher="CN=Nikola" Version="6.1.0.0" />
3+
<Identity Name="52b9212c-97a9-4639-9426-3e1ea9c1569e" Publisher="CN=Nikola" Version="7.0.0.0" />
44
<mp:PhoneIdentity PhoneProductId="52b9212c-97a9-4639-9426-3e1ea9c1569e" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
55
<Properties>
66
<DisplayName>Microsoft.Toolkit.Uwp.SampleApp</DisplayName>

Microsoft.Toolkit.Uwp.SampleApp/Pages/About.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
xmlns:animations="using:Microsoft.Toolkit.Uwp.UI.Animations"
55
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
87
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Pages"
98
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
109
xmlns:sampleapp="using:Microsoft.Toolkit.Uwp.SampleApp"
10+
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
1111
Loaded="Page_Loaded"
1212
mc:Ignorable="d">
1313

@@ -150,7 +150,7 @@
150150
<TextBlock Margin="0,20,0,0"
151151
FontSize="14"
152152
Foreground="{ThemeResource Brush-Link-Normal}"
153-
Text="The Windows Community Toolkit is a collection of helper functions, custom controls, and app services. It simplifies and demonstrates common developer patterns when building experiences for Windows 10."
153+
Text="The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks for building UWP and .NET apps for Windows 10."
154154
TextWrapping="Wrap" />
155155
</StackPanel>
156156

Microsoft.Toolkit.Uwp.SampleApp/Pages/SampleController.xaml.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
273273

274274
if (CurrentSample.HasDocumentation)
275275
{
276-
#pragma warning disable SA1008 // Opening parenthesis must be spaced correctly
277-
var (contents, path) = await CurrentSample.GetDocumentationAsync();
278-
#pragma warning restore SA1008 // Opening parenthesis must be spaced correctly
279-
documentationPath = path;
276+
var contents = await CurrentSample.GetDocumentationAsync();
280277
if (!string.IsNullOrWhiteSpace(contents))
281278
{
282279
DocumentationTextBlock.Text = contents;
@@ -431,9 +428,15 @@ private async void DocumentationTextBlock_OnLinkClicked(object sender, LinkClick
431428
{
432429
TrackingManager.TrackEvent("Link", e.Link);
433430
var link = e.Link;
434-
if (e.Link.EndsWith(".md"))
431+
if (link.EndsWith(".md"))
435432
{
436-
link = string.Format("https://docs.microsoft.com/en-us/windows/communitytoolkit/{0}/{1}", CurrentSample.CategoryName.ToLower(), link.Replace(".md", string.Empty));
433+
// Link to one of our other documents, so we'll construct the proper link here
434+
link = string.Format("https://docs.microsoft.com/windows/communitytoolkit/{0}/{1}", CurrentSample.RemoteDocumentationPath, link.Replace(".md", string.Empty));
435+
}
436+
else if (link.StartsWith("/"))
437+
{
438+
// We don't root our links to other docs.microsoft.com pages anymore, so we'll add it here.
439+
link = string.Format("https://docs.microsoft.com{0}", link);
437440
}
438441

439442
if (Uri.TryCreate(link, UriKind.Absolute, out Uri result))
@@ -450,7 +453,7 @@ private async void DocumentationTextBlock_ImageResolving(object sender, ImageRes
450453
// Determine if the link is not absolute, meaning it is relative.
451454
if (!Uri.TryCreate(e.Url, UriKind.Absolute, out Uri url))
452455
{
453-
url = new Uri(documentationPath + e.Url);
456+
url = new Uri(CurrentSample.LocalDocumentationFilePath + e.Url);
454457
}
455458

456459
if (url.Scheme == "ms-appx")
@@ -698,7 +701,6 @@ public bool UseBackground
698701

699702
private PaneState _paneState;
700703
private bool _onlyDocumentation;
701-
private string documentationPath;
702704

703705
private ThemeListener _themeListener;
704706

Loading

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ColorPicker/ColorPickerButtonPage.xaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)