[英]How to use defined color from App.xaml in Android style in xamarin forms
[英]How define style in App.xaml Xamarin Forms for CustomButton?
如何在App.xaml中為CustomButton定義樣式?
App.xaml中
<Style x:Key="CustomButtonSmall" TargetType="CustomButton">
<Setter Property="FontSize" Value="14" />
</Style>
MyPage.xaml
<local:CustomButton Text="{i18n:Translate CreateAccountButton}"
Grid.Column="0" Command="{Binding CreateAccountCommand}"
Type="Normal" Style="{StaticResource CustomButtonSmall}" />
您可以在例如Window.xaml中定義樣式:
<Window>
<Window.Resources>
<Style x:Key="myStyle" TargetType="Button">
<Setter Property="Background" Value="Orange" />
<Setter Property="FontStyle" Value="Italic" />
</Style>
</Window.Resources>
然后,您以此定位目標按鈕:
<Button Style="{StaticResource myStyle}">Buttontext</Button>
在App.xaml中
給CustomButton整個路徑,如TargetType =“ Control:CustomButton”,並在頂部定義Control,例如
xmlns:Control="clr-namespace:xyz"
<Style x:Key="CustomButtonSmall" TargetType="Control:CustomButton">
<Setter Property="FontSize" Value="14" />
</Style>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.