forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5274d9e
commit 452adda
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/Uno.UI/Microsoft/UI/Xaml/Controls/IconSource/ImageIconSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Media; | ||
|
||
namespace Microsoft.UI.Xaml.Controls | ||
{ | ||
public class ImageIconSource : IconSource | ||
{ | ||
public ImageSource ImageSource | ||
{ | ||
get => (ImageSource)GetValue(ImageSourceProperty); | ||
set => SetValue(ImageSourceProperty, value); | ||
} | ||
|
||
public static DependencyProperty ImageSourceProperty { get; } = | ||
DependencyProperty.Register(nameof(ImageSource), typeof(ImageSource), typeof(ImageIconSource), new PropertyMetadata(null, OnPropertyChanged)); | ||
|
||
internal protected override IconElement CreateIconElementCore() | ||
{ | ||
var imageIcon = new ImageIcon(); | ||
if (ImageSource is { } imageSource) | ||
{ | ||
imageIcon.Source = imageSource; | ||
} | ||
if (Foreground is { } newForeground) | ||
{ | ||
imageIcon.Foreground = newForeground; | ||
} | ||
return imageIcon; | ||
} | ||
|
||
internal protected override DependencyProperty GetIconElementPropertyCore(DependencyProperty sourceProperty) | ||
{ | ||
if (sourceProperty == ImageSourceProperty) | ||
{ | ||
return ImageIcon.SourceProperty; | ||
} | ||
|
||
return base.GetIconElementPropertyCore(sourceProperty); | ||
} | ||
} | ||
} |