xml - Xamarin:如何覆盖所有标签的标签样式类?
问题描述
在 nuget 包中有一个 Xaml 文件,其中包含:
<Style x:Key="LabelBase" TargetType="Label">
<Setter Property="TextColor" Value="Green" />
</Style>
<Style
BasedOn="{StaticResource LabelBase}"
Class="Primary"
TargetType="Label">
</Style>
在当前项目 App.xaml 我有:
<Style TargetType="Label">
<Setter Property="TextColor" Value="Red" />
</Style>
ResourceDictionary 具有MergedWith="XAMLFILE"
nuget .xaml 文件 ResourceDictionary。
在页面的 AbsoluteLayout 我有一个标签
<Label
Grid.Row="0"
FontSize="45"
HorizontalTextAlignment="Center"
StyleClass="Primary"
Text="Text Value"
VerticalOptions="Center" />
如何在我的项目 App.Xaml 中覆盖 Primary StyleClass 以使文本颜色继承红色而不创建新的 styleclass?
解决方案
如果您希望将该主题应用于所有标签,只需删除该类,它应该可以工作:
<Style
BasedOn="{StaticResource LabelBase}"
TargetType="Label">
</Style>
请注意您没有密钥并且样式在 APP.xaml 中
祝你好运
随意恢复。
推荐阅读
- jquery-animate - Jquery animate 函数不起作用:左侧属性的关键帧值无效
- c++ - Qt QSerialport 拔出设备未关闭
- r - 忽略未知的美学:填充
- python - TypeError: 'numpy.ndarray' 对象在为逻辑回归执行 RandomizedSearchCV 时不可调用
- javascript - 如果未检测到更改,如何使用 jquery/javascript 检测更改并防止在 GSP/HTML 中提交表单
- ios - 全球 iPhone 上的匹配时间 - 同步播放视频?
- oracle - 如何在 oracle 触发器中获取准确的更新列名?
- wordpress - 上传 wordpress 文件大小超过 10mb 的 Http 错误
- docker - 在 Raspberry Pi 3 B + 上拉取 arm32v7 Docker 容器镜像
- react-native - React Native:如何创建事件侦听器以在屏幕解锁和屏幕锁定时触发事件?