C#WPF标签字体未更改 [英] C# WPF label font is not changing

查看:63
本文介绍了C#WPF标签字体未更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个包含2个标签的自定义组件.我将它们的字体大小更改为更大,这是不可见的.没错,我看到了设计器的变化,但是当我启动该应用程序时,我仍然看到那个旧尺寸.

I have my own custom component that contains 2 labels. I changed font size for them to bigger one and it is not visible. To be correct, i see the change in designer, but when i launch the app i still see that old size.

字体大小甚至对于任何新创建的标签都不会更改.

Font size won't even change for any newly created label.

我的组件:

<Grid>
		<Label x:Name="lblName" Content="Label" Style="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="102" Height="34" FontWeight="Bold" VerticalContentAlignment="Center" FontFamily="Segoe UI" FontSize="18"/>
		<Label x:Name="lblNumber" Content="Label" Style="{x:Null}" HorizontalAlignment="Left" Margin="147,0,0,0" VerticalAlignment="Top" FontWeight="Bold" Height="33" Width="106" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Segoe UI" FontSize="18"/>
		<Button x:Name="btnPrev" Content="&lt; &lt;" HorizontalAlignment="Left" Margin="107,6,0,0" VerticalAlignment="Top" Width="35" Click="btnPrev_Click" Height="23"/>
		<Button x:Name="btnNext" Content="&gt; &gt;" HorizontalAlignment="Left" Margin="258,6,0,0" VerticalAlignment="Top" Width="35" Click="btnNext_Click" Height="23"/>

	</Grid>

我正在使用全局样式,请参见下文:

I'm using global styles, see below:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:AirServis">

	<!-- GLOBAL STYLES -->
	<Style TargetType="Button">
		<Setter Property="Height" Value="23" />
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="Label">
		<Setter Property="Height" Value="Auto" />
		<Setter Property="FontSize" Value="11" />
		<Setter Property="Padding" Value="5, 5, 5, 0" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="TextBox">
		<Setter Property="Height" Value="17" />
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="TabItem">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="TextBlock">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="ComboBox">
		<Setter Property="Height" Value="17" />
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="DatePicker">
		<Setter Property="Height" Value="17" />
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="DataGridColumnHeader">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style x:Key="TextBlockRightAligment" TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
		<Setter Property="TextAlignment" Value="Right" />
	</Style>

	<Style x:Key="TextBoxRightAligment" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
		<Setter Property="TextAlignment" Value="Right" />
	</Style>

	<Style TargetType="DataGrid">
		<Setter Property="RowHeaderWidth" Value="0" />
	</Style>

	<Style TargetType="GridViewColumnHeader">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="ListViewItem">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="ListView">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="CheckBox">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="VerticalContentAlignment" Value="Center" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

	<Style TargetType="DataGridCell">
		<Setter Property="FontSize" Value="11" />
		<Setter Property="FontFamily" Value="Arial" />
	</Style>

</ResourceDictionary>

感谢您提供有关此问题的建议:(

Thanks for any advice with this problem :(

希望我们可以一起解决! :)

Hope we can solve it together! :)

推荐答案

您是否尝试过重建项目然后运行它?
Have you tried rebuilding the project and then run it ?


这篇关于C#WPF标签字体未更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆