Mad*_*noy 8 xaml styles xamarin.forms
我们正在构建一个Xamarin Forms应用程序,我们注意到我们可以通过在App.xaml ResourceDictionary中创建样式来以两种方式设置元素样式
Class和StyleClass选项
在App.xaml中我们会写
<Style Class="EntryStandard" TargetType="Entry">
<Setter Property="TextColor" Value="#575e62" />
<Setter Property="BackgroundColor" Value="#9facb3" />
<Setter Property="FontSize" Value="14" />
</Style>
Run Code Online (Sandbox Code Playgroud)
然后,这将在其中一个内容页面中使用
<Entry StyleClass="EntryStandard" Placeholder="Login Name" Text="{Binding EntryEmailAddress}" />
Run Code Online (Sandbox Code Playgroud)
键和样式选项
这是我们在App.xaml下编写的内容
<Style x:Key="ButtonMainMenu_Purple" TargetType="Button">
<Setter Property="BackgroundColor" Value="#5d4785" />
<Setter Property="FontSize" Value="14" />
<Setter Property="TextColor" Value="#FFFFFF" />
</Style>
Run Code Online (Sandbox Code Playgroud)
然后我们在内容页面中使用以下内容
<Button Style="{StaticResource ButtonMainMenu_Purple}" Text="Friends" Command="{Binding OnFriendsButtonCommand}" />
Run Code Online (Sandbox Code Playgroud)
两者都很好,我只是想知道哪一个比另一个好,为什么?
| 归档时间: |
|
| 查看次数: |
1697 次 |
| 最近记录: |