【发布时间】:2019-06-29 12:41:56
【问题描述】:
我在 WPF 和 ResourceDictionary 中编写了一些样式和自定义控件。
现在我想在 xamarin 中使用这些样式,但我意识到该库应该基于要安装在 xamarin 上的 .NetStandard。
但现在我看到 ResourceDictionary 不存在。
如何将我的 WPF 代码升级到 xamarin?
【问题讨论】:
标签: c# wpf xaml xamarin resourcedictionary
我在 WPF 和 ResourceDictionary 中编写了一些样式和自定义控件。
现在我想在 xamarin 中使用这些样式,但我意识到该库应该基于要安装在 xamarin 上的 .NetStandard。
但现在我看到 ResourceDictionary 不存在。
如何将我的 WPF 代码升级到 xamarin?
【问题讨论】:
标签: c# wpf xaml xamarin resourcedictionary
很遗憾,Xamarin 无法使用 WPF 的 ResourceDictionary。
您可以Create and Consume a Xamarin's ResourceDictionary如下。
<Application ...>
<Application.Resources>
<ResourceDictionary>
<Color x:Key="PageBackgroundColor">Yellow</Color>
<Color x:Key="HeadingTextColor">Black</Color>
<Color x:Key="NormalTextColor">Blue</Color>
<Style x:Key="LabelPageHeadingStyle" TargetType="Label">
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="TextColor" Value="{StaticResource HeadingTextColor}" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
【讨论】: