Reputation: 46
I have added a new font "Renner.ttf" into resources of the project.
Then I tried to use it with a dynamic resource using <Windows.Resources/>
. In the design view it seems to be ok:
This is the actual font that I want so, then I build and run the project and that what I got:
This isn't the font I want, so what im doing wrong?
This is the code:
XAML:
<Window x:Class="MyProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MyProject"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="Renner">
<Setter Property="TextElement.FontFamily" Value="/MyProject;component/Resources/#Renner"/>
</Style>
</Window.Resources>
<Grid>
<TextBlock x:Name="lblTitle" Style="{DynamicResource Renner}" FontSize="72">
Reportes
</TextBlock>
<Button Width="150" Height="50" Click="Button_Click">
<TextBlock Style="{DynamicResource Renner}" FontSize="20">
Open New
</TextBlock>
</Button>
</Grid>
I have tried so far (without any luck):
<TextBlock FontSize="72" FontFamily="/MyProject;component/Resources/#Renner">Reportes</TextBlock>
Upvotes: 1
Views: 592
Reputation: 461
You will probably want to see BuildAction to Resource if you have not done so already.
Here is an MSDN article for reference: https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-3.5/ms753303(v=vs.90)
Upvotes: 2