我正在尝试遵循这个例子:
public class App : Application
{
public App ()
{
var buttonStyle = new Style (typeof(Button)) {
Setters = {
...
new Setter { Property = Button.TextColorProperty, Value = Color.Teal }
}
};
Resources = new ResourceDictionary ();
Resources.Add ("buttonStyle", buttonStyle);
...
}
...
}
但它不起作用/无法识别new ResourceDictionary()
。有谁知道我可能做错了什么?
最佳答案
您也可以将 setter 添加到样式的 Setters
集合中。 PCL 中的代码:
using Xamarin.Forms;
.....
this.Resources = new ResourceDictionary();
var style = new Style(typeof(Button));
style.Setters.Add(new Setter { Property = Button.TextColorProperty, Value = Color.Teal });
Resources.Add("MyButtonStyle", style);
关于xamarin - 如何在 Xamarin 中创建 ResourceDictionary?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45281369/