加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

xaml – Xamarin使用StyleClass和Style属性表单样式

发布时间:2020-12-14 18:41:01 所属栏目:资源 来源:网络整理
导读:我们正在构建一个Xamarin Forms应用程序,我们注意到我们可以通过在App.xaml ResourceDictionary中创建样式来以两种方式设置元素样式 Class和StyleClass选项 在App.xaml中我们会写 Style Class="EntryStandard" TargetType="Entry" Setter Property="TextColo
我们正在构建一个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>

然后,这将在其中一个内容页面中使用

<Entry StyleClass="EntryStandard" Placeholder="Login Name" Text="{Binding EntryEmailAddress}" />

键和样式选项

这是我们在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>

然后我们在内容页面中使用以下内容

<Button Style="{StaticResource ButtonMainMenu_Purple}" Text="Friends" Command="{Binding OnFriendsButtonCommand}" />

两者都很好,我只是想知道哪一个比另一个好,为什么?

解决方法

常规样式遵循标准的,相对不灵活的WPF模型.样式类包括级联语义,是新 theme支持的一部分.然而,它们的记录很少,而且还处于测试阶段.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读