Xaml 在xamarin表单中使用classid更改多个按钮的属性
我想使用classid更改多个按钮的BorderWidth属性。是否可能以xamarin形式存在。类似于Xamarin表单中的classid.BorderWidth=BorderWidth,要更改相同类型的多个控件的样式,必须使用Xaml 在xamarin表单中使用classid更改多个按钮的属性,xaml,xamarin,Xaml,Xamarin,我想使用classid更改多个按钮的BorderWidth属性。是否可能以xamarin形式存在。类似于Xamarin表单中的classid.BorderWidth=BorderWidth,要更改相同类型的多个控件的样式,必须使用样式类 您可以在应用程序级别或页面级别定义样式。以下是页面级别的样式定义: <ContentPage ....> <ContentPage.Resources> <Style x:Key="myBigButtonS
样式
类
您可以在应用程序
级别或页面
级别定义样式。以下是页面级别的样式定义:
<ContentPage ....>
<ContentPage.Resources>
<Style x:Key="myBigButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="Black" />
<Setter Property="BorderThickness" Value="10" />
</Style>
</ContentPage.Resources>
. . .
. . .
要应用样式,请执行以下操作:
<Button x:Name="button1" Style="{StaticResource myBigButtonStyle}" ... />
但是,如果要将此样式应用于页面的所有按钮,只需删除资源按钮样式键:
<Style TargetType="Button">
<Setter Property="Foreground" Value="Black" />
<Setter Property="BorderThickness" Value="10" />
</Style>
然后,不要对按钮应用任何样式:
<Button x:Name="button1" ... />
所有样式
类文档可在此处找到:
语法与html不同。但在最新版本的Xamarin中,您可以使用CSS文件应用样式。但这一选择仍然有限: