diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsPage.xaml index 2655dda17d8..8fc1cc881e5 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsPage.xaml +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsPage.xaml @@ -10,14 +10,15 @@ - + - + + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsXaml.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsXaml.bind index 48507ef0c43..b43e7139b03 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsXaml.bind +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/IconExtensions/IconExtensionsXaml.bind @@ -26,9 +26,9 @@ Style="{StaticResource BodyTextBlockStyle}"/> - - - + + + + + + + + + + + + + + + @@ -58,8 +76,8 @@ Width="300" Margin="12" Height="68"> - - + + - /// An abstract which to produce text-based icons. - /// - /// The type representing the glyph for the current icon. - public abstract class TextIconExtension : TextIconExtension - { - /// - /// Gets or sets the value representing the icon to display. - /// - public T Glyph { get; set; } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/BitmapIconSourceExtension.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/BitmapIconSourceExtension.cs new file mode 100644 index 00000000000..a506ddd93d0 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/BitmapIconSourceExtension.cs @@ -0,0 +1,37 @@ +// 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 System; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Markup; + +namespace Microsoft.Toolkit.Uwp.UI.Extensions +{ + /// + /// Custom which can provide values. + /// + [MarkupExtensionReturnType(ReturnType = typeof(BitmapIconSource))] + public sealed class BitmapIconSourceExtension : MarkupExtension + { + /// + /// Gets or sets the representing the image to display. + /// + public Uri Source { get; set; } + + /// + /// Gets or sets a value indicating whether to display the icon as monochrome. + /// + public bool ShowAsMonochrome { get; set; } + + /// + protected override object ProvideValue() + { + return new BitmapIconSource + { + ShowAsMonochrome = ShowAsMonochrome, + UriSource = Source + }; + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconExtension.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconExtension.cs index 1e1c800d442..553a8a282c1 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconExtension.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconExtension.cs @@ -12,8 +12,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Extensions /// Custom which can provide values. /// [MarkupExtensionReturnType(ReturnType = typeof(FontIcon))] - public class FontIconExtension : TextIconExtension + public class FontIconExtension : TextIconExtension { + /// + /// Gets or sets the value representing the icon to display. + /// + public string Glyph { get; set; } + /// /// Gets or sets the font family to use to display the icon. If , "Segoe MDL2 Assets" will be used. /// diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconSourceExtension.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconSourceExtension.cs index af2fe602587..7d2c961f4be 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconSourceExtension.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconSourceExtension.cs @@ -12,8 +12,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Extensions /// Custom which can provide values. /// [MarkupExtensionReturnType(ReturnType = typeof(FontIconSource))] - public class FontIconSourceExtension : TextIconExtension + public class FontIconSourceExtension : TextIconExtension { + /// + /// Gets or sets the value representing the icon to display. + /// + public string Glyph { get; set; } + /// /// Gets or sets the font family to use to display the icon. If , "Segoe MDL2 Assets" will be used. /// diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconExtension.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconExtension.cs index 414a33247c6..a0faebb1557 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconExtension.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconExtension.cs @@ -11,14 +11,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Extensions /// Custom which can provide symbol-baased values. /// [MarkupExtensionReturnType(ReturnType = typeof(FontIcon))] - public class SymbolIconExtension : TextIconExtension + public class SymbolIconExtension : TextIconExtension { + /// + /// Gets or sets the value representing the icon to display. + /// + public Symbol Symbol { get; set; } + /// protected override object ProvideValue() { var fontIcon = new FontIcon { - Glyph = unchecked((char)Glyph).ToString(), + Glyph = unchecked((char)Symbol).ToString(), FontFamily = SegoeMDL2AssetsFontFamily, FontWeight = FontWeight, FontStyle = FontStyle, diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconSourceExtension.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconSourceExtension.cs index f5b4e1725da..aaff4958c2a 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconSourceExtension.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/Markup/SymbolIconSourceExtension.cs @@ -11,14 +11,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Extensions /// Custom which can provide symbol-baased values. /// [MarkupExtensionReturnType(ReturnType = typeof(FontIconSource))] - public class SymbolIconSourceExtension : TextIconExtension + public class SymbolIconSourceExtension : TextIconExtension { + /// + /// Gets or sets the value representing the icon to display. + /// + public Symbol Symbol { get; set; } + /// protected override object ProvideValue() { var fontIcon = new FontIconSource { - Glyph = unchecked((char)Glyph).ToString(), + Glyph = unchecked((char)Symbol).ToString(), FontFamily = SegoeMDL2AssetsFontFamily, FontWeight = FontWeight, FontStyle = FontStyle, diff --git a/UnitTests/UnitTests.UWP/UnitTestApp.xaml b/UnitTests/UnitTests.UWP/UnitTestApp.xaml index f9e9631c047..ab5fb38f2f8 100644 --- a/UnitTests/UnitTests.UWP/UnitTestApp.xaml +++ b/UnitTests/UnitTests.UWP/UnitTestApp.xaml @@ -9,7 +9,7 @@ - + + IconSource="{extensions:SymbolIconSource Symbol=Play}"/> + +