【发布时间】:2016-09-08 04:02:06
【问题描述】:
我正在使用带有 Xamarin Studio 的 Mac 机器上的 PCL 创建我的第一个 xamarin 表单应用程序。 我阅读了很多文章来为应用程序创建全局样式,但我无法访问在 App.xaml.cs 文件中声明的应用程序内的任何文件的样式。我在下面提到了我使用的一些代码。或者,如果有人有其他选择可以让它变得容易或无论如何可能,请建议我。提前致谢。
App.xaml.cs-
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="DinePerfect.App">
<Application.Resources>
<ResourceDictionary>
<Style x:Key="btnStyle" TargetType="Button">
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="CenterAndExpand" />
<Setter Property="BorderColor" Value="Lime" />
<Setter Property="BorderRadius" Value="5" />
<Setter Property="BorderWidth" Value="5" />
<Setter Property="WidthRequest" Value="200" />
<Setter Property="TextColor" Value="Teal" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
在其他文件中调用样式-
<Button Text="Login" Style="{StaticResource btnStyle} TextColor="Black" BackgroundColor="#9C661F" Clicked="btnLoginClicked" />
【问题讨论】:
标签: xaml styles xamarin.forms