Skip to content

Commit eb785c4

Browse files
committed
Adding icon property to project template + xaml styling
1 parent 666a83c commit eb785c4

File tree

9 files changed

+13
-7
lines changed

9 files changed

+13
-7
lines changed

CommunityToolkit.App.Shared/Converters/StringToUriConverter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using CommunityToolkit.App.Shared.Helpers;
6+
57
namespace CommunityToolkit.App.Shared.Converters;
68

79
public class StringToUriConverter : IValueConverter
810
{
911
public object Convert(object value, Type targetType, object parameter, string language)
1012
{
11-
return new Uri("ms-appx:///SourceAssets/" + (string)value);
13+
return new Uri(IconHelper.GetIconPath((string)value));
1214
}
1315

1416
public object ConvertBack(object value, Type targetType, object parameter, string language)

CommunityToolkit.App.Shared/Helpers/IconHelper.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace CommunityToolkit.App.Shared.Helpers;
88

99
public static class IconHelper
1010
{
11+
internal const string SourceAssetsPrefix = "ms-appx:///SourceAssets/";
12+
1113
public static IconElement? GetCategoryIcon(ToolkitSampleCategory category)
1214
{
1315
IconElement? iconElement = null;
@@ -22,4 +24,9 @@ public static class IconHelper
2224
}
2325
return iconElement;
2426
}
27+
28+
public static string GetIconPath(string IconPath)
29+
{
30+
return SourceAssetsPrefix + IconPath;
31+
}
2532
}

CommunityToolkit.App.Shared/Helpers/NavigationViewHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static class NavigationViewHelper
4545
yield return new MUXC.NavigationViewItem
4646
{
4747
Content = metadata.Title,
48-
Icon = new BitmapIcon() { ShowAsMonochrome = false, UriSource = new Uri("ms-appx:///SourceAssets/" + metadata.Icon) }, // TO DO: This is probably a property we need to add to ToolkitFrontMatter?
48+
Icon = new BitmapIcon() { ShowAsMonochrome = false, UriSource = new Uri(IconHelper.GetIconPath(metadata.Icon)) }, // TO DO: This is probably a property we need to add to ToolkitFrontMatter?
4949
Tag = metadata,
5050
};
5151
}

CommunityToolkit.App.Shared/Pages/GettingStartedPage.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
</Page.Resources>
3737
<Grid BorderBrush="{ThemeResource NavigationViewContentGridBorderBrush}"
3838
CornerRadius="8,0,0,0">
39-
4039
<Grid.RowDefinitions>
4140
<RowDefinition Height="Auto" />
4241
<RowDefinition Height="*" />

CommunityToolkit.App.Shared/Pages/Shell.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using CommunityToolkit.App.Shared.Renderers;
66
using CommunityToolkit.Tooling.SampleGen.Metadata;
77
using CommunityToolkit.App.Shared.Helpers;
8-
using Microsoft.UI.Xaml.Controls;
98

109
namespace CommunityToolkit.App.Shared.Pages;
1110

@@ -62,6 +61,7 @@ private void NavView_ItemInvoked(MUXC.NavigationView sender, MUXC.NavigationView
6261
NavigationFrame.Navigate(typeof(SettingsPage));
6362
}
6463
}
64+
6565
// Check if Getting Started page
6666
else if (selectedItem.Tag != null && selectedItem.Tag.GetType() == typeof(string))
6767
{
@@ -116,7 +116,6 @@ private void NavigationFrameOnNavigated(object sender, NavigationEventArgs navig
116116
}
117117
else if (navigationEventArgs.Parameter.GetType() == typeof(ToolkitFrontMatter))
118118
{
119-
120119
EnsureNavigationSelection(((ToolkitFrontMatter)navigationEventArgs.Parameter).FilePath);
121120
}
122121
}

CommunityToolkit.App.Shared/Styles/Buttons.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
66
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
77

8-
98
<SolidColorBrush x:Key="SubtleButtonBackground"
109
Color="{ThemeResource SubtleFillColorTransparent}" />
1110
<SolidColorBrush x:Key="SubtleButtonBackgroundPointerOver"

CommunityToolkit.App.Shared/Styles/ItemTemplates.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
</Image>
8282
</Grid>
8383

84-
8584
<RelativePanel Grid.Column="1"
8685
Grid.ColumnSpan="2"
8786
Margin="16,6,0,0">
6.05 KB
Loading

ProjectTemplate/samples/ProjectTemplate.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ category: Controls
99
subcategory: Layout
1010
discussion-id: 0
1111
issue-id: 0
12+
icon: assets/icon.png
1213
---
1314

1415
<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/contribute/markdown-reference -->

0 commit comments

Comments
 (0)