Skip to content

Commit dfd46ab

Browse files
author
Anjali
committed
Merge branch 'feature/win11theming/staging' of https://github.com/dotnet/wpf into PasswordBox
2 parents 7506742 + 2c6df32 commit dfd46ab

File tree

16 files changed

+1156
-158
lines changed

16 files changed

+1156
-158
lines changed

src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/PresentationFramework-ref.baseline.txt

Lines changed: 32 additions & 4 deletions
Large diffs are not rendered by default.

src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,9 @@
668668
<Compile Include="System\Windows\Controls\IconElement\IconSourceElementConverter.cs" />
669669
<Compile Include="System\Windows\Controls\IconElement\SymbolIcon.cs" />
670670
<Compile Include="System\Windows\Controls\SymbolIconExtension.cs" />
671+
<Compile Include="System\Windows\Controls\FontIconExtension.cs" />
672+
<Compile Include="System\Windows\Controls\ImageIconExtension.cs" />
673+
<Compile Include="System\Windows\Controls\IconElement\ImageIcon.cs" />
671674
<Compile Include="System\Windows\Controls\IconSource\IconSource.cs" />
672675
<Compile Include="System\Windows\Controls\IconSource\SymbolIconSource.cs" />
673676
<Compile Include="System\Windows\Controls\IconSource\FontIconSource.cs" />
@@ -1171,6 +1174,8 @@
11711174
<Compile Include="System\Windows\Localization.cs" />
11721175
<Compile Include="System\Windows\LogicalTreeHelper.cs" />
11731176
<Compile Include="System\Windows\LostFocusEventManager.cs" />
1177+
<Compile Include="System\Windows\ControlsDictionary.cs" />
1178+
<Compile Include="System\Windows\ThemesDictionary.cs" />
11741179
<Compile Include="System\Windows\Markup\AttributeData.cs" />
11751180
<Compile Include="System\Windows\Markup\Baml2006\Baml2006KeyRecord.cs" />
11761181
<Compile Include="System\Windows\Markup\Baml2006\Baml2006KnownTypes.cs" />
@@ -1210,7 +1215,6 @@
12101215
<Compile Include="System\Windows\Markup\BamlRecordWriter.cs" />
12111216
<Compile Include="System\Windows\Markup\BamlVersionHeader.cs" />
12121217
<Compile Include="System\Windows\Markup\BamlWriter.cs" />
1213-
<Compile Include="System\Windows\Markup\ControlsDictionary.cs" />
12141218
<Compile Include="System\Windows\Markup\DependencyPropertyConverter.cs" />
12151219
<Compile Include="System\Windows\Markup\FilteredXmlReader.cs" />
12161220
<Compile Include="System\Windows\Markup\IHaveResources.cs" />
@@ -1244,7 +1248,6 @@
12441248
<Compile Include="System\Windows\Markup\TemplateKeyConverter.cs" />
12451249
<Compile Include="System\Windows\Markup\ThemeResource.cs" />
12461250
<Compile Include="System\Windows\Markup\ThemeResourceExtension.cs" />
1247-
<Compile Include="System\Windows\Markup\ThemesDictionary.cs" />
12481251
<Compile Include="System\Windows\Markup\TypeContext.cs" />
12491252
<Compile Include="System\Windows\Markup\WpfXamlLoader.cs" />
12501253
<Compile Include="System\Windows\Markup\XamlBrushSerializer.cs" />

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Appearance/ApplicationThemeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static class ApplicationThemeManager
3838
{
3939
private static ApplicationTheme _cachedApplicationTheme = ApplicationTheme.Unknown;
4040

41-
internal const string LibraryNamespace = "PresentationFramework.win11;";
41+
internal const string LibraryNamespace = "win11;";
4242

4343
internal const string ThemesDictionaryPath = "pack://application:,,,/PresentationFramework.Win11;component/Resources/Theme/";
4444

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This Source Code Form is subject to the terms of the MIT License.
2+
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
3+
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
4+
// All Rights Reserved.
5+
6+
using System.Windows.Markup;
7+
using System.Windows.Media;
8+
using System.Windows.Controls;
9+
10+
namespace System.Windows.Markup;
11+
12+
/// <summary>
13+
/// Custom <see cref="MarkupExtension"/> which can provide <see cref="FontIcon"/>.
14+
/// </summary>
15+
/// <example>
16+
/// <code lang="xml">
17+
/// &lt;ui:Button
18+
/// Appearance="Primary"
19+
/// Content="WPF UI button with font icon"
20+
/// Icon="{ui:FontIcon '&#x1F308;'}" /&gt;
21+
/// </code>
22+
/// <code lang="xml">
23+
/// &lt;ui:Button Icon="{ui:FontIcon '&amp;#x1F308;'}" /&gt;
24+
/// </code>
25+
/// <code lang="xml">
26+
/// &lt;ui:HyperlinkButton Icon="{ui:FontIcon '&amp;#x1F308;'}" /&gt;
27+
/// </code>
28+
/// <code lang="xml">
29+
/// &lt;ui:TitleBar Icon="{ui:FontIcon '&amp;#x1F308;'}" /&gt;
30+
/// </code>
31+
/// </example>
32+
[ContentProperty(nameof(Glyph))]
33+
[MarkupExtensionReturnType(typeof(FontIcon))]
34+
public class FontIconExtension : MarkupExtension
35+
{
36+
public FontIconExtension(string glyph)
37+
{
38+
Glyph = glyph;
39+
FontFamily = new FontFamily("FluentSystemIcons");
40+
}
41+
42+
public FontIconExtension(string glyph, FontFamily fontFamily)
43+
: this(glyph)
44+
{
45+
FontFamily = fontFamily;
46+
}
47+
48+
[ConstructorArgument("glyph")]
49+
public string Glyph { get; set; }
50+
51+
[ConstructorArgument("fontFamily")]
52+
public FontFamily FontFamily { get; set; }
53+
54+
public double FontSize { get; set; }
55+
56+
public override object ProvideValue(IServiceProvider serviceProvider)
57+
{
58+
var fontIcon = new FontIcon { Glyph = Glyph, FontFamily = FontFamily };
59+
60+
if (FontSize > 0)
61+
{
62+
fontIcon.FontSize = FontSize;
63+
}
64+
65+
return fontIcon;
66+
}
67+
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/IconElement/ImageIcon.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
44
// All Rights Reserved.
55

6+
using System.Windows.Media;
67
// ReSharper disable once CheckNamespace
78
namespace System.Windows.Controls;
89

@@ -28,13 +29,13 @@ public class ImageIcon : IconElement
2829
/// <summary>
2930
/// Gets or sets the Source on this Image.
3031
/// </summary>
31-
public ImageSource? Source
32+
public ImageSource Source
3233
{
3334
get => (ImageSource)GetValue(SourceProperty);
3435
set => SetValue(SourceProperty, value);
3536
}
3637

37-
protected System.Windows.Controls.Image? Image;
38+
protected System.Windows.Controls.Image Image;
3839

3940
protected override UIElement InitializeChildren()
4041
{
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// This Source Code Form is subject to the terms of the MIT License.
2+
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
3+
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
4+
// All Rights Reserved.
5+
6+
using System.Windows.Markup;
7+
using System.Windows.Media;
8+
9+
using System.Windows.Controls;
10+
11+
namespace System.Windows.Markup;
12+
13+
/// <summary>
14+
/// Custom <see cref="MarkupExtension"/> which can provide <see cref="ImageIcon"/>.
15+
/// </summary>
16+
/// <example>
17+
/// <code lang="xml">
18+
/// &lt;ui:Button
19+
/// Appearance="Primary"
20+
/// Content="WPF UI button with font icon"
21+
/// Icon="{ui:ImageIcon '/my-icon.png'}" /&gt;
22+
/// </code>
23+
/// <code lang="xml">
24+
/// &lt;ui:Button Icon="{ui:ImageIcon 'pack://application:,,,/Assets/wpfui.png'}" /&gt;
25+
/// </code>
26+
/// <code lang="xml">
27+
/// &lt;ui:HyperlinkButton Icon="{ui:ImageIcon 'pack://application:,,,/Assets/wpfui.png'}" /&gt;
28+
/// </code>
29+
/// <code lang="xml">
30+
/// &lt;ui:TitleBar Icon="{ui:ImageIcon 'pack://application:,,,/Assets/wpfui.png'}" /&gt;
31+
/// </code>
32+
/// </example>
33+
[ContentProperty(nameof(Source))]
34+
[MarkupExtensionReturnType(typeof(ImageIcon))]
35+
public class ImageIconExtension : MarkupExtension
36+
{
37+
public ImageIconExtension(ImageSource source)
38+
{
39+
Source = source;
40+
}
41+
42+
[ConstructorArgument("source")]
43+
public ImageSource Source { get; set; }
44+
45+
public double Width { get; set; } = 16D;
46+
47+
public double Height { get; set; } = 16D;
48+
49+
public override object ProvideValue(IServiceProvider serviceProvider)
50+
{
51+
var imageIcon = new ImageIcon
52+
{
53+
Source = Source,
54+
Width = Width,
55+
Height = Height
56+
};
57+
58+
return imageIcon;
59+
}
60+
}

0 commit comments

Comments
 (0)