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

兰州专业做网站的公司哪家好新闻头条今日新闻下载

兰州专业做网站的公司哪家好,新闻头条今日新闻下载,大连市城乡建设委员会网站,客户网站建设完成后需要什么一、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.ds6.com.cn/news/92822.html

相关文章:

  • 新乡做新网站专业关键词排名软件
  • dw做网站时怎么改为绝对路径seo谷歌
  • 网站的日常维护主要包括推广的几种方式
  • 做淘宝头像的网站有哪些百度入口网站
  • 青岛日文网站制作重庆百度开户
  • 上海品牌网站建设如何推销网站
  • 做餐厅logo用什么软件网站教育培训网站官网
  • 沭阳网站建设龙岗网站建设公司
  • 力洋网站建设公司广告发布
  • 湘潭做网站找磐石网络一流杭州网站优化咨询
  • 怎样用记事本做网站网络营销咨询公司
  • 分类信息网站如何做优化2023广州疫情最新消息今天
  • css div网站百度手机助手app下载并安装
  • 市场营销策划方案模板网站制作优化
  • 做坏事网站seo的基本工作内容
  • 自己做网站用中文为什么是乱码网站seo平台
  • dedecms5.7装饰公司网站模板河南专业网站建设
  • 北京住房和城乡建设部网站seo基础
  • 专业网站设计联系方式百度建站
  • 北海购物网站开发设计怎么在百度上做公司网页
  • 做商品批发的网站谷歌搜索引擎入口2022
  • 网站建设框架构建安徽seo优化规则
  • 温州英文seoseo优化网站推广专员招聘
  • 深情密码免费观看网站口碑营销方案
  • 集团网站建设要多少钱中国教师教育培训网
  • 网站外链的建设长春建站服务
  • 男女做姿抽插视频有网站吗网站seo整站优化
  • 网站开发 武汉搜索关键词排名
  • 重庆网站如何做推广网络营销的特点有哪些特点
  • 优化网站流量seo自学教程推荐