我最近更新到最新的 Xamarin 表单预发布 4.2 版本。我遇到的一个值得注意的重大变化是 - 假设我有以下风格:
<Style x:Key="LightTextLabelStyle" TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource TextLight}" />
<Setter Property="FontSize" Value="15" />
<Setter Property="TextColor" Value="{StaticResource greyishBrown}" />
</Style>
在以前的版本中,跨度和标签都支持相同的目标“标签”。就像 - 这是以前的工作:
<Label Margin="0,6,0,0">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding PriceText}" Style="{StaticResource LightTextLabelStyle}" FontSize="13" />
<Span Text="{Binding BidAmount, StringFormat=' {0:C0}' TargetNullValue=' Pending'}" Style="{StaticResource LightTextLabelStyle}" FontSize="13" />
</FormattedString>
</Label.FormattedText>
</Label>
针对 Label 的相同样式也支持 Span。但是现在在新版本中它没有。
我的问题是:我们可以同时支持具有相同样式的标签和跨度吗?我们不能为两者都定位相同的风格吗?就像我尝试了以下但它没有编译:
<Style x:Key="LightTextLabelStyle" TargetType="Label, Span">
<Setter Property="FontFamily" Value="{StaticResource TextLight}" />
<Setter Property="FontSize" Value="15" />
<Setter Property="TextColor" Value="{StaticResource greyishBrown}" />
</Style>
请帮我。我可以复制粘贴样式并制作两种不同的样式;如果有更好的方法?