目前我正在开发一个 UI 库,它应该包含自定义 UI 元素、布局和对话框,以便拥有一致且可重用的 UI 集合。
在我的项目中,目前的结构如下:
- UILib(库的共享代码)
- UILib.Droid(包含自定义渲染等的android库)
- UILib.iOS(包含自定义渲染器等的 iOS 库)
- UILibDemo(使用库的演示应用程序的共享代码)
- UILibDemo.Droid(Android 演示应用程序)
- UILibDemo.iOS(演示应用程序 iOS)
在我的库中,我有一个类“LoadingDialog”,到目前为止工作正常。但是我的问题是我现在正在尝试定义一种样式以从演示应用程序的共享代码 (App.xaml) 中更改 LoadingDialog 的某些属性:
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dialogs="clr-namespace:UILib.Dialogs;assembly=UILib"
x:Class="BetterUIDemo.App">
<Application.Resources>
<ResourceDictionary>
<x:String x:Key="DefaultFontLight">OpenSans-Light.ttf</x:String>
<Color x:Key="ThemeColor">#f08c00</Color>
<Color x:Key="BackgroundColor">#37474f</Color>
<Style x:Key="LoadingDialogStyle" TargetType="dialogs:LoadingDialog">
<Setter Property="ThrobberBackgroundColor" Value="White" />
<Setter Property="LabelFontFamily" Value="{DynamicResource DefaultFontLight}" />
<Setter Property="LabelColor" Value="{DynamicResource ThemeColor}" />
<Setter Property="LoadingText" Value="Lade Daten ..." />
</Style>
</ResourceDictionary>
</Application.Resources>
我的 LoadingDialog 类也包含这些属性:
#region Properties
public static BindableProperty ThrobberBackgroundColorProperty = BindableProperty.Create("ThrobberBackgroundColor", typeof(Color), typeof(Color), Color.Black);
public static BindableProperty FontFamilyProperty = BindableProperty.Create("FontFamily", typeof(string), typeof(string), Font.Default.FontFamily);
public static BindableProperty LabelColorProperty = BindableProperty.Create("LabelColor", typeof(Color), typeof(Color), Color.Black);
public static BindableProperty LoadingTextProperty = BindableProperty.Create("LoadingText", typeof(string), typeof(string), "Loading ...");
public string LabelFontFamily
{
get { return (string)GetValue(FontFamilyProperty); }
set { SetValue(FontFamilyProperty, value); }
}
public Color ThrobberBackgroundColor
{
get { return (Color)GetValue(ThrobberBackgroundColorProperty); }
set { SetValue(ThrobberBackgroundColorProperty, value); }
}
public string LoadingText
{
get { return (string)GetValue(LoadingTextProperty); }
set { SetValue(LoadingTextProperty, value); }
}
public Color LabelColor
{
get { return (Color)GetValue(LabelColorProperty); }
set { SetValue(LabelColorProperty, value); }
}
#endregion
但是,当我尝试编译演示应用程序时,出现以下错误:
严重性代码描述项目文件行抑制状态错误位置 14:13。无法在 LoadingDialog UILibDemo C:\Work\UILib\UILibDemo\UILibDemo\App.xaml 14 上解析 LabelFontFamily
有什么建议我可能做错了吗?