首页后端开发ASP.NETUWP中设置控件样式四种方法

UWP中设置控件样式四种方法

时间2024-01-30 19:28:03发布访客分类ASP.NET浏览390
导读:收集整理的这篇文章主要介绍了UWP中设置控件样式四种方法 ,觉得挺不错的,现在分享给大家,也给大家做个参考。1.隐式方法,通过仅指定 Style 的 TargetTyPE。(设置全部的Button样式 1 <Page.Resourc...
收集整理的这篇文章主要介绍了UWP中设置控件样式四种方法 ,觉得挺不错的,现在分享给大家,也给大家做个参考。1.隐式方法,通过仅指定 Style 的 TargetTyPE。(设置全部的Button样式)


1 Page.Resources >
    2         Style TargetType="Button">
    3             Setter PRoperty="Borderbrush" Value="Lime"/>
    4             Setter Property="BorderThickness" Value="4"/>
    5         /Style>
    6     /Page.Resources>

2.显式方法,通过指定 Style 的 TargetType 和 x:Key 特性这一特性,然后通过使用显式键的 { staticResource} 标记扩展引用设置目标控件的 Style 属性


Page.Resources >
            Style x:Key="BTnStyle" TargetType="Button">
                Setter Property="BorderBrush" Value="Lime"/>
                Setter Property="BorderThickness" Value="4"/>
            /Style>
     /Page.Resources>
//调用Button Content="跳转方法" x:Name="btntest" Style="{
StaticResource btnStyle}
    "/>
    

3.单个样式表示


//1.App.xaML配置文件中Application.Resources>
         SolIDColorBrush x:Key="BlueBrush" Color="#FF1C90D1"/>
    /Application.Resources>
//2.页面中绑定值MainPage.xamlRectangle Height="2" Width="18" Fill="{
StaticResource EggshellBrush}
    "/>
    //3.获取值MainPage.xaml.csApp.current.Resources["EggshellBrush"] as SolidColorBrush

4.使用样式文件进行调整样式

1) 创建文件夹Themes右键添加新建项Visual C# àxamlà资源字典 style.xaml

2) 在style.xaml写样式例如

Style TargetType="Button" x:Key="gft_FormBtm">
            Setter Property="Background" Value="Orangered">
    /Setter>
            Setter Property="Height" Value="50">
    /Setter>
            Setter Property="FontSize" Value="16">
    /Setter>
            Setter Property="Foreground" Value="WhITe">
    /Setter>
            Setter Property="HorizontalAlignment" Value="center">
    /Setter>
            Setter Property="minWidth" Value="300">
    /Setter>
     /Style>
    

3) 在App.xaml文件中指定资源


!--4.使用样式文件-->
        Application.Resources>
            ResourceDictionary>
                ResourceDictionary.MergedDictionaries>
                    ResourceDictionary Source="Themes/style.xaml">
    /ResourceDictionary>
                /ResourceDictionary.MergedDictionaries>
            /ResourceDictionary>
    /Application.Resources>
    

4) 在xaml界面中使用样式文件

1 Button x:Name="btnSubmit"  Content="同意以上协议并注册" HorizontalAlignment="Center" Click="btnSubmit_Click" Style="{
StaticResource gft_FormBtm}
    " />
    

以上就是UWP中设置控件样式四种方法 的详细内容,更多请关注其它相关文章!

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

四种方法

若转载请注明出处: UWP中设置控件样式四种方法
本文地址: https://pptw.com/jishu/592940.html
jquery实现点击加一个数字 用户管理和权限和设置——mysql

游客 回复需填写必要信息