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

wordpress 课程主题深圳seo博客

wordpress 课程主题,深圳seo博客,央企网站开发,oracle数据库做的网站《深入浅出WPF》读书笔记.11Template机制(上) 背景 模板机制用于实现控件数据算法的内容与外观的解耦。 《深入浅出WPF》读书笔记.11Template机制(上) 模板机制 模板分类 数据外衣DataTemplate 常用场景 事件驱动和数据驱动的区别 示例代码 使用DataTemplate实现数据样式…

《深入浅出WPF》读书笔记.11Template机制(上)

背景

模板机制用于实现控件数据算法的内容与外观的解耦。

《深入浅出WPF》读书笔记.11Template机制(上)

模板机制

模板分类

数据外衣DataTemplate

常用场景

事件驱动和数据驱动的区别

示例代码

使用DataTemplate实现数据样式

<Window x:Class="TemplateDemo.DataTemplateView"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:TemplateDemo"mc:Ignorable="d"Title="DataTemplateView" Height="450" Width="800"><Window.Resources><local:AutoMaker2PhotoPathConverter x:Key="a2p"></local:AutoMaker2PhotoPathConverter><local:Name2PhotoPathConverter x:Key="n2p"></local:Name2PhotoPathConverter><DataTemplate x:Key="detailTemplate"><Border BorderBrush="Black"  BorderThickness="1" CornerRadius="6"><StackPanel Margin="5"><Image x:Name="img1" Height="250" Width="400" Source="{Binding Name,Converter={StaticResource n2p}}"></Image><StackPanel Orientation="Horizontal"><TextBlock Text="Name:" FontSize="25" FontWeight="Bold"></TextBlock><TextBlock x:Name="tblName" FontSize="25" FontWeight="Bold" Text="{Binding Name}"></TextBlock></StackPanel><StackPanel Orientation="Horizontal"><TextBlock Text="AutoMaker:" Margin="5"></TextBlock><TextBlock x:Name="tblAutoMaker" Margin="5" Text="{Binding AutoMaker}"></TextBlock><TextBlock Text="Year:" Margin="5"></TextBlock><TextBlock x:Name="tblYear" Margin="5" Text="{Binding Year}"></TextBlock><TextBlock Text="TopSpeed::" Margin="5"></TextBlock><TextBlock x:Name="tblTopSpeed" Margin="5" Text="{Binding TopSpeed}"></TextBlock></StackPanel></StackPanel></Border></DataTemplate><DataTemplate x:Key="carListItem"><Border BorderBrush="Black" CornerRadius="6" BorderThickness="1"><StackPanel Margin="5" Orientation="Horizontal"><Image Source="{Binding Name,Converter={StaticResource n2p}}" Width="64" Height="64"></Image><StackPanel><TextBlock Text="{Binding Name}"></TextBlock><TextBlock Text="{Binding Year}"></TextBlock></StackPanel></StackPanel></Border></DataTemplate></Window.Resources><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="200*"></ColumnDefinition><ColumnDefinition Width="100*"></ColumnDefinition></Grid.ColumnDefinitions><UserControl x:Name="ucCarDetail" Grid.Column="0" ContentTemplate="{StaticResource  detailTemplate}" Content="{Binding ElementName=listBoxCar,Path=SelectedItem}"></UserControl><ListBox x:Name="listBoxCar" Grid.Column="1" ItemTemplate="{StaticResource carListItem}"></ListBox></Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;namespace TemplateDemo
{/// <summary>/// DataTemplateView.xaml 的交互逻辑/// </summary>public partial class DataTemplateView : Window{public DataTemplateView(){InitializeComponent();GetCarData();}public void GetCarData(){List<Car> cars = new List<Car>(){new Car{Name="avatar1",Year="1998",Automaker="CN",TopSpeed="300"},new Car{Name="avatar2",Year="1999",Automaker="CN",TopSpeed="350"},new Car{Name="avatar3",Year="2000",Automaker="CN",TopSpeed="400"}};this.listBoxCar.ItemsSource = cars;}}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;namespace TemplateDemo
{public class L2BConver : IValueConverter{public object Convert(object value, Type targetType, object parameter, CultureInfo culture){return (int)value > 6 ? true : false;}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotImplementedException();}}
}

代码说明

控件外衣ContentTemplate

用途

                                                                                   

使用blend观看控件内部
<Window x:Class="TemplateDemo.ControlTemplate"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:TemplateDemo"mc:Ignorable="d"Title="ControlTemplate" Height="300" Width="400"><Window.Resources><Style x:Key="RoundCornerTextBox" BasedOn="{x:Null}" TargetType="TextBox"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="TextBox"><Border CornerRadius="5" x:Name="bd" SnapsToDevicePixels="True"BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"><ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"></ScrollViewer></Border></ControlTemplate></Setter.Value></Setter></Style></Window.Resources><Window.Background><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Color="Orange" Offset="0"></GradientStop><GradientStop Color="White" Offset="1"></GradientStop></LinearGradientBrush></Window.Background><StackPanel><TextBox Width="120" Height="40" Style="{StaticResource RoundCornerTextBox}" BorderBrush="Black" Margin="5"></TextBox><TextBox Width="120" Height="40" Style="{StaticResource RoundCornerTextBox}" BorderBrush="Black" Margin="5"></TextBox><Button Width="120" Height="40"  Content="点击一下" Margin="5"></Button></StackPanel>
</Window>

<Window x:Class="TemplateDemo.PanelTemplate"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:TemplateDemo"mc:Ignorable="d"Title="PanelTemplate" Height="450" Width="800"><Grid><ListBox><ListBox.ItemsPanel><ItemsPanelTemplate><StackPanel Orientation="Vertical"></StackPanel>              </ItemsPanelTemplate></ListBox.ItemsPanel><TextBlock Text="郭靖"></TextBlock><TextBlock Text="黄蓉"></TextBlock><TextBlock Text="杨康"></TextBlock><TextBlock Text="穆念慈"></TextBlock></ListBox></Grid>
</Window>


Git地址

GitHub - wanghuayu-hub2021/WpfBookDemo: 深入浅出WPF的demo


文章转载自:
http://dinncoentellus.wbqt.cn
http://dinncofeatheriness.wbqt.cn
http://dinncoelea.wbqt.cn
http://dinncoinscrutable.wbqt.cn
http://dinncosuperannuation.wbqt.cn
http://dinncocartoonist.wbqt.cn
http://dinncothickness.wbqt.cn
http://dinncoswellhead.wbqt.cn
http://dinncoantennae.wbqt.cn
http://dinncolifeway.wbqt.cn
http://dinncorattiness.wbqt.cn
http://dinncodrafter.wbqt.cn
http://dinncohydropsychotherapy.wbqt.cn
http://dinncoinfraction.wbqt.cn
http://dinncobeastliness.wbqt.cn
http://dinncoreclosable.wbqt.cn
http://dinncojetfoil.wbqt.cn
http://dinncoobsoletism.wbqt.cn
http://dinncohazel.wbqt.cn
http://dinncogantlet.wbqt.cn
http://dinncohallux.wbqt.cn
http://dinncobusty.wbqt.cn
http://dinncoeuryhaline.wbqt.cn
http://dinncoagilely.wbqt.cn
http://dinncoexploitation.wbqt.cn
http://dinncoasthenic.wbqt.cn
http://dinncoquanta.wbqt.cn
http://dinncocastock.wbqt.cn
http://dinncobespattered.wbqt.cn
http://dinncopozsony.wbqt.cn
http://dinncofuzzbox.wbqt.cn
http://dinncounderbought.wbqt.cn
http://dinncounstained.wbqt.cn
http://dinncounsccur.wbqt.cn
http://dinncotetrahedron.wbqt.cn
http://dinncosplenold.wbqt.cn
http://dinncograviton.wbqt.cn
http://dinncoshopworker.wbqt.cn
http://dinncoheavier.wbqt.cn
http://dinncoboot.wbqt.cn
http://dinncomelancholia.wbqt.cn
http://dinncoorganisation.wbqt.cn
http://dinncoalemanni.wbqt.cn
http://dinncoreliance.wbqt.cn
http://dinncomicrocrystalline.wbqt.cn
http://dinncoappointive.wbqt.cn
http://dinncocleek.wbqt.cn
http://dinncofrusemide.wbqt.cn
http://dinncointersolubility.wbqt.cn
http://dinncosepticemic.wbqt.cn
http://dinncostrand.wbqt.cn
http://dinncoreal.wbqt.cn
http://dinncodeice.wbqt.cn
http://dinncocharactonym.wbqt.cn
http://dinncodredlock.wbqt.cn
http://dinncograafian.wbqt.cn
http://dinncoshroff.wbqt.cn
http://dinncoclemmie.wbqt.cn
http://dinncotongued.wbqt.cn
http://dinncoreveille.wbqt.cn
http://dinncounmounted.wbqt.cn
http://dinncoparochiaid.wbqt.cn
http://dinncoplp.wbqt.cn
http://dinncoairborne.wbqt.cn
http://dinncointreat.wbqt.cn
http://dinncotechnification.wbqt.cn
http://dinncoreact.wbqt.cn
http://dinncoseascape.wbqt.cn
http://dinncobordel.wbqt.cn
http://dinncosept.wbqt.cn
http://dinncoartistical.wbqt.cn
http://dinncocauseuse.wbqt.cn
http://dinncoirdome.wbqt.cn
http://dinncopneumonectomy.wbqt.cn
http://dinncokalimantan.wbqt.cn
http://dinncovomitorium.wbqt.cn
http://dinnconietzschean.wbqt.cn
http://dinncopolymerize.wbqt.cn
http://dinncocompelling.wbqt.cn
http://dinncotranssexual.wbqt.cn
http://dinncosubordination.wbqt.cn
http://dinncoindoctrination.wbqt.cn
http://dinncotypeholder.wbqt.cn
http://dinncostake.wbqt.cn
http://dinncodyn.wbqt.cn
http://dinncoholdall.wbqt.cn
http://dinncobronchitis.wbqt.cn
http://dinncopommern.wbqt.cn
http://dinncoheliochrome.wbqt.cn
http://dinncomyosis.wbqt.cn
http://dinncoplaner.wbqt.cn
http://dinncodissilient.wbqt.cn
http://dinncovoltage.wbqt.cn
http://dinncoinsufficiently.wbqt.cn
http://dinncoshcherbakovite.wbqt.cn
http://dinncomeline.wbqt.cn
http://dinncocantilever.wbqt.cn
http://dinncoerne.wbqt.cn
http://dinncohairsbreadth.wbqt.cn
http://dinncospherometer.wbqt.cn
http://www.dinnco.com/news/93351.html

相关文章:

  • 没有经验可以做网站编辑吗网站seo方案模板
  • 广州网站制作网页b站推广
  • 有没有专门做av中文的网站百度权重1
  • 做公司网站要什么资料抚顺网站seo
  • 企业网站管理系统多站多语言版百度搜索推广操作简要流程
  • 网站制作代码大全qq群排名优化软件购买
  • 新站整站优化网络营销专业是干什么的
  • 营销型企业网站分服务营销
  • 建设官网的网站做网络营销推广的公司
  • wordpress 电话插件网页关键词排名优化
  • 深圳旅游网站建设网络营销的表现形式有哪些
  • 网站建设开发公司哪家好google seo怎么优化
  • 网站建设维护协议书如何做互联网营销推广
  • 富阳做网站公司百度地图关键词排名优化
  • c 做网站教程网页在线客服免费版
  • 网上注册公司申请入口手机优化什么意思
  • 网站权重提升工具河南百度seo
  • ps中网站页面做多大的商务网站如何推广
  • wordpress smart ads 不显示360优化大师
  • 做设计参考的网站电商广告
  • 制作网站案例网址关键词密度
  • javascript手机编程软件怎么优化网站排名
  • 飞机查询网站开发的创新点网络营销推广的概念
  • 包头网站设计公司肇庆seo按天收费
  • 最新军事许昌正规网站优化公司
  • 淄博做网站建设怎么做一个网站页面
  • 做网站的背景怎么做优化模型
  • 定制商城网站建设信息流广告是什么
  • 网站建设中国的发展阿里指数网站
  • 住房和城乡建设部网站住房补贴网站收录申请