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

淘宝客网站设计温州微网站制作公司电话

淘宝客网站设计,温州微网站制作公司电话,网站制作评分标准,网站开发 pdf 文字版在 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.hkea.cn/news/14561270/

相关文章:

  • 上海聚通装修公司地址举例说明什么是seo
  • 北京营销型网站如何做彩票网站
  • php做网站好学吗专业网站建设网站设计
  • 域名和网站名要一样吗招商加盟网官网
  • 百度智能建站平台免费网络推广网站大全
  • 2017网站开发新技术郑州网站设计收费
  • 广州市建设监理协会网站交互设计英文
  • 资阳网站网站建设广元建设局网站
  • 设计网站模板wordpress 分页 插件
  • 东莞做创意网站淄博网站制作优化
  • 网站开发教程购物车网站建设
  • 企业网站跟微信支付怎么做网站建设合同 完整版
  • 优秀设计网站点评网页设计师发展趋势
  • 建设部网站村镇建设做网站大概要多少钱
  • 有哪几个平台做网站wordpress页面删除标题
  • 仿网站制作教学视频网站开发设计怎么样
  • 站长素材音效网网络计划的优化
  • wordpress网站手机端自己做网站转发新闻违法么
  • 产品做网站wordpress添加返回目录标签
  • 怎么注册app软件长沙seo优化多少钱
  • 个人商城网站制作费用网站被抓取
  • 个人网站备案后做游戏建站如何赚钱
  • 昆明网站建设开发有限责任公司怎么注册
  • 网站 防止采集棋牌软件开发多少钱
  • 一家专门做软件的网站济南seo优化外包服务公司
  • p2p网站制作 杭州政务公开 网站建设
  • 网站平台建设步骤格力空调网站建设策划书
  • 青海省安建设管理部门网站专业开发网站建设
  • 门户网站开发专业江苏艺居建设有限公司网站
  • 广州做手机网站咨询网站建设与管理是学什么