Skip to content

Commit cd656a5

Browse files
committed
Another attempted fix for #746
1 parent 8b8da7e commit cd656a5

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@
3535
-->
3636

3737
</ResourceDictionary.MergedDictionaries>
38-
39-
40-
41-
42-
43-
44-
4538
</ResourceDictionary>
4639
</UserControl.Resources>
4740

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
using System;
22
using System.IO;
3+
using System.Windows;
4+
using System.Windows.Markup;
35
using System.Windows.Media;
46

57
namespace MaterialDesignThemes.Wpf
68
{
7-
public static class MaterialDesignFonts
9+
[MarkupExtensionReturnType(typeof(FontFamily))]
10+
public class MaterialDesignFont : MarkupExtension
811
{
9-
private static readonly Lazy<FontFamily> _roboto
10-
= new Lazy<FontFamily>(LoadRobotoFontFamily);
11-
12-
private static FontFamily LoadRobotoFontFamily()
12+
private static readonly Lazy<FontFamily> _roboto
13+
= new Lazy<FontFamily>(() =>
14+
new FontFamily(new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/"), "./#Roboto"));
15+
16+
public override object ProvideValue(IServiceProvider serviceProvider)
1317
{
14-
string fontDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Roboto");
15-
return new FontFamily(new Uri($"file:///{fontDirectory}"), "./#Roboto");
18+
return _roboto.Value;
1619
}
17-
18-
public static FontFamily Roboto => _roboto.Value;
1920
}
2021
}

0 commit comments

Comments
 (0)