当前位置: 首页 > news >正文

移动网站 用户体验怎样在网站上做免费的网业

移动网站 用户体验,怎样在网站上做免费的网业,深圳建网站兴田德润可信,国内最有趣的网站目录 前言一、Style1.1 例子1.2 为样式起名字1.3 BasedOn 继承上一个样式 二、外部StyleStep1 创建资源字典BaseButtonStyle.xamlStep2 在资源字典中写入StyleStep3 App.xaml中写引用路径【全局】Step4 调用三、代码提供四、x:Key和x:Name区别 更新时间 前言 参考文章&#xff…

目录

  • 前言
  • 一、Style
    • 1.1 例子
    • 1.2 为样式起名字
    • 1.3 BasedOn 继承上一个样式
  • 二、外部Style
    • Step1 创建资源字典BaseButtonStyle.xaml
    • Step2 在资源字典中写入Style
    • Step3 App.xaml中写引用路径【全局】
    • Step4 调用
    • 三、代码提供
    • 四、x:Key和x:Name区别
  • 更新时间


前言

参考文章:
参考视频:【WPF入门教程 Visual Studio 2022】WPF界面开发入门

自己的感想


一、Style

如下图所示,在Windows.Resources中设置的Style属性,只在当前界面产生效果。
在这里插入图片描述

1.1 例子

在这里插入图片描述

<Window x:Class="WPF_Study.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_Study"mc:Ignorable="d"Title="WPF入门.txt" Height="600" Width="800"><Window.Resources><Style TargetType="Button"><Setter Property="Background" Value="Red"/><Setter Property="FontSize" Value="20"/><Setter Property="Height" Value="40"/><Setter Property="Width" Value="70"/></Style></Window.Resources><StackPanel><Button Content="登录" /><Button Content="帮助" /><Button Content="退出" /></StackPanel></Window>

1.2 为样式起名字

为啥要起别名?1.1中的案例导致所有的Button组件都是这个红色样式,但是如果我们只想让退出按钮为红色,其他三个按钮为绿色,该怎么操作?
在这里插入图片描述

<Window x:Class="WPF_Study.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_Study"mc:Ignorable="d"Title="WPF入门.txt" Height="600" Width="800"><Window.Resources><Style x:Key="QuitStyle" TargetType="Button"><Setter Property="Background" Value="Red"/><Setter Property="FontSize" Value="20"/><Setter Property="Height" Value="40"/><Setter Property="Width" Value="70"/></Style><Style x:Key="loginStyle" TargetType="Button"><Setter Property="Background" Value="Green"/><Setter Property="FontSize" Value="20"/><Setter Property="Height" Value="40"/><Setter Property="Width" Value="70"/></Style></Window.Resources><StackPanel><Button Style="{StaticResource loginStyle}" Content="登录" /><Button Style="{StaticResource loginStyle}" Content="帮助" /><Button Style="{StaticResource QuitStyle}" Content="退出" /></StackPanel></Window>

1.3 BasedOn 继承上一个样式

在这里插入图片描述

<Window x:Class="WPF_Study.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_Study"mc:Ignorable="d"Title="WPF入门.txt" Height="600" Width="800"><Window.Resources><Style TargetType="Button"><Setter Property="Background" Value="WhiteSmoke"/><Setter Property="FontSize" Value="20"/><Setter Property="Margin" Value="20,10"/></Style><Style x:Key="QuitStyle" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"><Setter Property="Background" Value="Red"/></Style><Style x:Key="loginStyle" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"><Setter Property="Background" Value="Green"/></Style></Window.Resources><StackPanel><Button Style="{StaticResource loginStyle}" Content="登录" /><Button Content="帮助" /><Button Style="{StaticResource QuitStyle}" Content="退出" /></StackPanel></Window>

二、外部Style

需要我们把style放入xaml文件中。

Step1 创建资源字典BaseButtonStyle.xaml

在这里插入图片描述

Step2 在资源字典中写入Style

在这里插入图片描述

Step3 App.xaml中写引用路径【全局】

在这里插入图片描述

Step4 调用

在这里插入图片描述


三、代码提供

C# WPF中的Style写入xaml中进行全局引用——点击下载代码


四、x:Key和x:Name区别

  • 在Resources中进行唯一标定。

在这里插入图片描述
在这里插入图片描述


更新时间

  • 2025-02-06:创建。
  • 2025-02-07:补充x:key和x:name之间区别。
http://www.yayakq.cn/news/169892/

相关文章:

  • 做营销网站公司企业形象设计英文
  • 成品网站开发有哪些做排球比赛视频网站
  • 佛山做网站设计制作价格建设自己的网站
  • 深圳做网站de怎么样更好的做网站
  • 网站建设平台对比江夏区做网站
  • 设计网站登录框ps怎么做wordpress挣钱
  • 广州网站设计总部如何用flashfxp通过ftp访问网站服务器下载网站代码
  • 网页制作做网站左侧导航广州市品牌网站建设平台
  • 建筑工地招工网网站如何优化流程
  • 自己做网站都要什么手续网络广告的收费模式有
  • 泰安哪里有做网站app的个人摄影网站模版
  • 国内最专业的设计网站建设网络程序设计实验报告
  • 有没有免费的网站软件做网站是不是很简单
  • 铁岭房地产网站建设网站建设实训过程报告
  • 网站建设师个人简介怎么写同城类网站建设多少钱
  • 购物网站的后台做哪些东西网站与数据库
  • 网站建设竞争对数分析武威网站建设
  • 东莞网站优化费用电子商务网站开发的意义
  • 网站建设平台分析手机百度seo怎么优化
  • 网站做多宽做足球预测的网站
  • 网站建设销售销售流程图网站安排
  • 网站做排名有用吗昆明专业网站排名推广
  • 网站 项目 需求固镇建设局网站
  • wordpress建站有广告吗新增域名网站建设方案
  • 网站的建设会计入哪个科目青海高等级公路建设管理局网站
  • 网站开发者工具的网络选项做网站多久才会有收益
  • 住房城乡建设部网站职业资格网站建设很简单
  • 做一个网站推广wordpress js效果
  • 做化验的网站新浪门户网站是谁做的
  • 平面设计网站模板上海某家具网站建设方案