WPF使用程序集资源
程序集资源
- 添加程序集资源
Build Action 需设置为Embedded Resource
- 使用程序集资源
<TextBlock Text="{x:Static prop:Resources.Company}" FontSize="20" HorizontalAlignment="Center">
<TextBlock.RenderTransform>
<ScaleTransform >
</ScaleTransform>
</TextBlock.RenderTransform>
<TextBlock.Foreground>
<LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1">
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="Blue" Offset="1"/>
</LinearGradientBrush>
</TextBlock.Foreground>
</TextBlock>
<TextBlock Text="{x:Static prop:Resources.Pwd}">
</TextBlock>
在XAML中需添加 xmlns:prop="clr-namespace:WpfApp4.Properties"
- 运行效果