Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF资源字体未更新_C#_Wpf_Xaml_Fonts_Dynamicresource - Fatal编程技术网

C# WPF资源字体未更新

C# WPF资源字体未更新,c#,wpf,xaml,fonts,dynamicresource,C#,Wpf,Xaml,Fonts,Dynamicresource,我在项目的资源中添加了一个新字体“Renner.ttf”。 然后我尝试使用将其与动态资源一起使用。在“设计”视图中,似乎还可以: 这是我想要的实际字体,然后我构建并运行项目,我得到: 这不是我想要的字体,我做错了什么 代码如下: XAML: 报道 打开新的 到目前为止,我已经尝试过(没有任何运气): 清理项目并重建它 在没有资源的情况下使用它报告 安装字体并在没有本地资源的情况下像使用其他字体一样使用它 删除资源并重新添加 若您还并没有看到BuildAction to Resource

我在项目的资源中添加了一个新字体“Renner.ttf”。 然后我尝试使用
将其与动态资源一起使用。在“设计”视图中,似乎还可以:

这是我想要的实际字体,然后我构建并运行项目,我得到:

这不是我想要的字体,我做错了什么

代码如下:

XAML:


报道
打开新的

到目前为止,我已经尝试过(没有任何运气):

  • 清理项目并重建它
  • 在没有资源的情况下使用它<代码>报告
  • 安装字体并在没有本地资源的情况下像使用其他字体一样使用它
  • 删除资源并重新添加

  • 若您还并没有看到BuildAction to Resource,那个么您可能希望看到它

    以下是一篇MSDN文章供参考:

    <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>