Я пытаюсь установить семейство шрифтов для всех своих страниц ...
В моем главном окне, содержащем рамку для страницы, у меня есть следующее:
<Window.Style>
<Style TargetType="{x:Type Window}">
<Setter Property="FontFamily" Value="Fonts/Gotham Rounded Light.OTF#Gotham Rounded Light" />
</Style>
</Window.Style>
<Window.Triggers>
И в моем коде MainWindow у меня есть это:
Style = (Style)FindResource(typeof(Window));
Шрифт страницы все еще не меняется, хотя .... Есть идеи, что я могу делать неправильно?Я не уверен, как главное окно отразится в его стиле на всех созданных страницах
Код позади App.xaml
using Engine;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
namespace V
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
Window mainWindow = null;
string dllToLoad = null;
App()
{
Startup += App_Startup;
}
void App_Startup(object sender, StartupEventArgs e)
{
try
{
ReadJson();
Window wnd = LoadRunTimeDLL();
wnd.WindowState = WindowState.Minimized;
wnd.Show();
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(string.Format("Failed to load window from{0} - {1}", "OtherWindow", ex.Message));
throw new Exception(String.Format("Failed to load window from{0} - {1}", "OtherWindow", ex.Message), ex);
}
}
private void ReadJson()
{
using (StreamReader r = new StreamReader("../../Config/Config.json"))
{
string json = r.ReadToEnd();
var jsonData = JsonConvert.DeserializeObject<RootObject>(json);
dllToLoad = jsonData.DllToLoad;
}
}
private Window LoadRunTimeDLL()
{
string assemblyName = string.Format("{0}\\{1}.dll",
new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, dllToLoad);
if (assemblyName != null)
{
Assembly asm = Assembly.LoadFile(assemblyName);
Type[] tlist = asm.GetTypes();
foreach (Type t in tlist)
{
if (t.Name == "MainWindow")
{
mainWindow = Activator.CreateInstance(t) as Window;
break;
}
}
}
return mainWindow;
}
}
}
И App.XAML
<Application x:Class="V.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:V" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
</Application>