Skip to content

Commit 4ff5fc9

Browse files
committed
Added BitmapIconSourceExtension type
1 parent 43c28eb commit 4ff5fc9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using Windows.UI.Xaml.Controls;
7+
using Windows.UI.Xaml.Markup;
8+
9+
namespace Microsoft.Toolkit.Uwp.UI.Extensions
10+
{
11+
/// <summary>
12+
/// Custom <see cref="MarkupExtension"/> which can provide <see cref="BitmapIconSource"/> values.
13+
/// </summary>
14+
[MarkupExtensionReturnType(ReturnType = typeof(BitmapIconSource))]
15+
public sealed class BitmapIconSourceExtension : MarkupExtension
16+
{
17+
/// <summary>
18+
/// Gets or sets the <see cref="Uri"/> representing the image to display.
19+
/// </summary>
20+
public Uri Source { get; set; }
21+
22+
/// <summary>
23+
/// Gets or sets a value indicating whether to display the icon as monochrome.
24+
/// </summary>
25+
public bool ShowAsMonochrome { get; set; }
26+
27+
/// <inheritdoc/>
28+
protected override object ProvideValue()
29+
{
30+
return new BitmapIconSource
31+
{
32+
ShowAsMonochrome = ShowAsMonochrome,
33+
UriSource = Source
34+
};
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)