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

h5case是什么网站php网站开发 vip

h5case是什么网站,php网站开发 vip,做环保的网站有哪些,做lol直播网站在 WPF#xff08;Windows Presentation Foundation#xff09;中#xff0c;模板是一种强大的机制#xff0c;用于定义控件的外观。它允许你将控件的逻辑#xff08;功能#xff09;和外观#xff08;UI#xff09;分离开来。例如#xff0c;一个按钮控件#xff0c… 在 WPFWindows Presentation Foundation中模板是一种强大的机制用于定义控件的外观。它允许你将控件的逻辑功能和外观UI分离开来。例如一个按钮控件其默认外观是由微软定义的但通过模板你可以完全改变按钮的外观如改变它的形状、颜色、添加动画效果等。 模板主要有两种类型ControlTemplate用于定义控件的可视结构和 DataTemplate用于定义数据对象的可视化表示。 1. 控件模板ControlTemplate 1.1 在本文件中定义模板 下面XAML文件定义了两个模板分别是Button和label控件的在界面正文时就可以直接调用资源中的控件模板 Window x:ClassTemplate.Views.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:prismhttp://prismlibrary.com/prism:ViewModelLocator.AutoWireViewModelTrueTitle{Binding Title} Height350 Width525 Window.Resources!-- 定义按钮控件模板 --ControlTemplate x:KeyMyButtonTemplate TargetTypeButtonBorder BackgroundLightBlue BorderBrushDarkBlue BorderThickness2 CornerRadius5ContentPresenter HorizontalAlignmentCenter VerticalAlignmentCenter//Border/ControlTemplate!--定义Label控件模板--ControlTemplate x:KeyLabelTemplate TargetTypeLabelBorder BackgroundLightBlue BorderBrushDarkBlue BorderThickness2 CornerRadius5ContentPresenter HorizontalAlignmentCenter VerticalAlignmentCenter//Border/ControlTemplate/Window.ResourcesGridStackPanel!-- 使用控件模板 --Button Template{StaticResource MyButtonTemplate} ContentButton 1 Width100 Height50/Button Template{StaticResource MyButtonTemplate} ContentButton 2 Width100 Height50/Label Template{StaticResource LabelTemplate } Content123 Width100 Height40//StackPanel/Grid /Window 1.2 分离资源文添加模板 也可以将资源文件脱离出来单独管理便于在多个界面中使用同一模板 先添加资源文件 编辑资源文件 ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml!-- 定义按钮控件模板 --ControlTemplate x:KeyMyButtonTemplate TargetTypeButtonBorder BackgroundLightBlue BorderBrushDarkBlue BorderThickness2 CornerRadius5ContentPresenter HorizontalAlignmentCenter VerticalAlignmentCenter//Border/ControlTemplate!--定义Label控件模板--ControlTemplate x:KeyLabelTemplate TargetTypeLabelBorder BackgroundLightBlue BorderBrushDarkBlue BorderThickness2 CornerRadius5ContentPresenter HorizontalAlignmentCenter VerticalAlignmentCenter//Border/ControlTemplate/ResourceDictionary 呈现效果跟方法一是一样的 2. 数据模板DataTemplate 2.1 定义数据模型 public class Staff {public string Name { get; set; }public int Age { get; set; } } 2.2 在资源文件中定义模板 ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml!-- 定义按钮控件模板 --ControlTemplate x:KeyMyButtonTemplate TargetTypeButtonBorder BackgroundLightBlue BorderBrushDarkBlue BorderThickness2 CornerRadius5ContentPresenter HorizontalAlignmentCenter VerticalAlignmentCenter//Border/ControlTemplate!--定义Label控件模板--ControlTemplate x:KeyLabelTemplate TargetTypeLabelBorder BackgroundLightBlue BorderBrushDarkBlue BorderThickness2 CornerRadius5ContentPresenter HorizontalAlignmentCenter VerticalAlignmentCenter//Border/ControlTemplate!--定义数据模板--DataTemplate x:KeyStaffDataTemplateStackPanelTextBlock TextName: FontWeightBold/TextBlock Text{Binding Name} FontWeightBold/TextBlock TextAge: FontWeightBold/TextBlock Text{Binding Age} ForegroundGray//StackPanel/DataTemplate/ResourceDictionary 2.3 初始化数据模型 这里用了Prism框架 public class MainWindowViewModel : BindableBase {private string _title Prism Application;public string Title{get { return _title; }set { SetProperty(ref _title, value); }}private ObservableCollectionStaff _people;public ObservableCollectionStaff People{get { return _people; }set { SetProperty(ref _people, value); }}public MainWindowViewModel(){// 初始化数据People new ObservableCollectionStaff{new Staff { Name Alice, Age 25 },new Staff { Name Bob, Age 30 },new Staff { Name Charlie, Age 35 }};} } 2.4 应用数据模板绑定数据 Window x:ClassTemplate.Views.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:prismhttp://prismlibrary.com/prism:ViewModelLocator.AutoWireViewModelTrueTitle{Binding Title} Height350 Width525 Window.Resources!-- 引用外部的资源字典 --ResourceDictionary SourceControlTemplates.xaml//Window.ResourcesGridStackPanel!-- 使用控件模板 --Button Template{StaticResource MyButtonTemplate} ContentButton 1 Width100 Height50/Button Template{StaticResource MyButtonTemplate} ContentButton 2 Width100 Height50/Label Template{StaticResource LabelTemplate } Content123 Width100 Height40/!--这样--ListBox ItemTemplate{StaticResource StaffDataTemplate} ItemsSource{Binding People}/ListBox!--或者这样--StackPanelListBox ItemsSource{Binding People} ItemTemplate{StaticResource StaffDataTemplate}//StackPanel/StackPanel/Grid /Window运行效果 3. 基于模板的样式 StylewithTemplates 3.1 在资源字典中定义一个样式 ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml!--定义样式--Style x:KeyMyButtonStyle TargetTypeButtonSetter PropertyBackground ValueLightGreen/Setter PropertyForeground ValueWhite/Setter PropertyFontWeight ValueBold//Style /ResourceDictionary 3.2 使用样式 Window x:ClassTemplate.Views.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:prismhttp://prismlibrary.com/prism:ViewModelLocator.AutoWireViewModelTrueTitle{Binding Title} Height350 Width525 Window.Resources!-- 引用外部的资源字典 --ResourceDictionary SourceControlTemplates.xaml //Window.ResourcesGridStackPanel!-- 使用样式 --Button Style{StaticResource MyButtonStyle} ContentButton 1 Width100 Height50/Button Style{StaticResource MyButtonStyle} ContentButton 2 Width100 Height50/Button Style{StaticResource MyButtonStyle} ContentButton 3 Width100 Height50/Button Style{StaticResource MyButtonStyle} ContentButton 4 Width100 Height50//StackPanel/Grid /Window运行效果 4. WPF的模板资源 HandyControl这是一套比较流行的 WPF 控件库几乎重写了所有原生样式并且包含 80 余款自定义控件。在其开源项目中有大量的模板定义和使用案例对于想要快速构建美观的 WPF 应用程序的开发者来说非常有价值。你可以访问HandyControl 的 GitHub 页面获取相关资源。Panuon.WPF.UI该组件库能帮助开发者快速完成样式和控件的 UI 设计提供了大量的属性来方便地修改 WPF 中一些常用的效果而这些效果的实现往往涉及到模板的使用。你可以在Panuon.WPF.UI 的 GitHub 页面上找到相关的代码和示例。ModernUI提供了基于 ModernUI 1.0.4 的 win8 极简化界面设计有丰富的界面组件和样式支持插件化开发便于扩展和维护。你可以从ModernUI 的项目地址获取相关资源。
http://www.w-s-a.com/news/184588/

相关文章:

  • 毕业室内设计代做网站广东建设监理协会网站个人账号
  • 百度推广点击收费标准自己如何做网站优化
  • 安徽省建设监理网站广州澄网站建设公司
  • 做简历用什么网站俄罗斯搜索引擎浏览器官网入口
  • dw里响应式网站怎么做制作网站需要多少时间
  • 网站如何做双链路示范学校建设专题网站
  • 网站开发北京影视网站seo描述
  • 高端网站定制建设公司哪家好企业网络推广技巧
  • 建设公司网站的内容建筑设计图片
  • 用ps怎么做网站的效果图互联网营销师报名入口官网
  • 网站的后端怎么开发网站 白名单
  • 济宁中小企业网站建设wordpress爆破工具
  • 零基础网站建设视频商城系统平台有哪些
  • 那个网站做百科好过wordpress删除
  • 优化网站排名怎么制作网站建设数据库模板
  • 哪个建站软件比较好带论坛都有什么公司需要网站建设
  • 同城便民网站开发自己免费怎么制作网站吗
  • 数据库网站开发教程网站内部优化是什么意思
  • 哈尔滨建站怎么做广西seo快速排名
  • 公司网站建设的不足企业文档管理wordpress
  • .net做的网站代码网站怎么加二级域名
  • 网站建设方案对比分析报告成都短视频代运营
  • 企业所得税税率知多少重庆seo什么意思
  • ftp如何修改网站备案号百度云建站
  • 免费做网站空间dede二手车网站源码
  • 网站服务器需要多大设计网站公司开发
  • asp 网站权限设计做网站业务员
  • 做棋牌网站违法嘛网络服务网络推广
  • 专门做推广的网站吗免费建域名网站
  • 在百度做网站株洲网站平台搭建