1、Window页面这样引用
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/COSMO.IM.Resources;component/Css/DataGridCss.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="contentCenterStyle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="{x:Type Label}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
</Style>
</ResourceDictionary>
</Window.Resources>
2、用户控件页面这样引用
<UserControl.Resources>
<ResourceDictionary>
<Style x:Key="dgCell" TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/COSMO.IM.Resources;component/Css/DataGridCss.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>