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

兰州专业做网站的公司哪家好电脑零基础培训学校

兰州专业做网站的公司哪家好,电脑零基础培训学校,商丘做网站哪家好,wordpress 模特模板一、DataTemplate 在WPF(Windows Presentation Foundation)中,DataTemplate 用于定义数据的可视化呈现方式。它允许你自定义如何展示数据对象,从而实现更灵活和丰富的用户界面。DataTemplate 通常用于控件(如ListBox、…

一、DataTemplate

在WPF(Windows Presentation Foundation)中,DataTemplate 用于定义数据的可视化呈现方式。它允许你自定义如何展示数据对象,从而实现更灵活和丰富的用户界面。DataTemplate 通常用于控件(如ListBoxComboBoxDataGrid等)的项模板。

1.代码示例

1.1 xaml.cs

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.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;namespace 学习
{public partial class MainWindow : Window{public MainWindow(){InitializeComponent();List<Color> test = new List<Color>();test.Add(new Color() { Code = "Red", Name = "红色" });test.Add(new Color() { Code = "BLUE", Name = "蓝色" });test.Add(new Color() { Code = "YELLOW", Name = "黄色" });test.Add(new Color() { Code = "GREEN", Name = "绿色" });list.ItemsSource = test;}}public class Color{public string Code { get; set; }public string Name { get; set; }}
}

1.2 xaml

<Window x:Class="学习.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:学习"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><ListBox x:Name="list"><ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal"><Border Width="10" Height="10"Background="{Binding Code}"></Border><TextBlock Margin="10,0" Text="{Binding Name}"></TextBlock></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></Grid>
</Window>

2.代码结果

3.代码示例2

后端不变

<Window x:Class="学习.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:学习"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><DataGridx:Name="list"AutoGenerateColumns="False"CanUserAddRows="False"><DataGrid.Columns><DataGridTextColumn Binding="{Binding Name}" Header="Name"/><DataGridTextColumn Binding="{Binding Code}" Header="Code"/><DataGridTemplateColumn Header="操作"><!--可操作的--><DataGridTemplateColumn.CellTemplate><DataTemplate><StackPanel Orientation="Horizontal"><Border Width="10"Height="10"Background="{Binding Code}"></Border><TextBlock Margin="10" Text="{Binding Name}"></TextBlock></StackPanel></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn></DataGrid.Columns></DataGrid></Grid>
</Window>

4.代码结果

http://www.tj-hxxt.cn/news/39100.html

相关文章:

  • 网络营销外包服务商对seo的认识和理解
  • 网站会员收费怎么做新站seo优化快速上排名
  • 企业宣传片制作app宁波seo外包服务平台
  • 济南网站seo技术如何推广网站方法
  • 网站设计怎么学网站怎么收录到百度
  • 织梦多个网站关键词优化的主要工具
  • java做网站的主要技术建一个外贸独立站大约多少钱
  • ai做网站seo搜索引擎优化哪家好
  • 百度怎么开户做网站app代理推广合作
  • 运输网站建设西安seo计费管理
  • 统计网站怎么做百度推广托管公司
  • 网站上的动效是用ae做的深圳网络推广的公司
  • 展示网站动画怎么做的绍兴seo推广
  • 政府网站建设管理会议主持词6网络推广怎样做
  • 临沂制作网站多少钱网络推广优化服务
  • 网站怎么做视频的软件seo网站是什么意思
  • 网站建设比选文件推广软件免费
  • 商城网站建设平台女装标题优化关键词
  • 做贷款网站seo课程培训中心
  • 网站平台报价模板下载宁波网络推广方式
  • 网站的手机版m站怎么做网络搜索工具
  • 深圳网站制作收费魔方优化大师官网
  • java可以做网站前端吗营销策划方案案例
  • 井研移动网站建设郑州技术支持seo
  • 网站建设优化服务如何营销型网站有哪些
  • 先做网站还是先申请域名体育新闻最新消息
  • 做直播网站软件有哪些软件下载网络软文推广案例
  • 厦门正规网站建设多少网络营销课程主要讲什么内容
  • 电影网站开发api百度爱采购怎样入驻
  • 做的好的企业网站seo技术培训宁波