110,953
社区成员
发帖
与我相关
我的任务
分享
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14"></Setter>
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="14"></Setter>
</Style>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib">
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14"></Setter>
</Style>
<DataTemplate DataType="{x:Type System:String}">
<TextBlock Text="{Binding}">
<TextBlock.Resources>
<Style TargetType="{x:Type TextBlock}"/>
</TextBlock.Resources>
</TextBlock>
</DataTemplate>
</ResourceDictionary>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14"></Setter>
</Style>
</ResourceDictionary>
using System.Windows;
using MvvmLight1.ViewModel;
using System;
namespace MvvmLight1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// Initializes a new instance of the MainWindow class.
/// </summary>
public MainWindow()
{
InitializeComponent();
InitializeTheme();
}
private void InitializeTheme()
{
App.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("Skins/MainSkin.xaml", UriKind.Relative)) as ResourceDictionary);
}
}
}
<Grid x:Name="LayoutRoot">
<StackPanel>
<TextBlock Text="这是字体"
FontWeight="Bold"
Foreground="Purple"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap" />
<Button Content="这是字体" Width="150" Height="30" FontSize="10"></Button>
</StackPanel>
</Grid>