当前位置: 首页 > 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.yayakq.cn/news/103884/

相关文章:

  • 做网站之前需要准备什么网站建设需要了解哪些信息
  • 海南旅游网站建设方式内蒙e登记官网最新
  • 网站备案 深圳贵州交通建设集团有限公司网站
  • 综合网站开发实训总结做招聘信息的网站有哪些
  • 建设一个有影响力的网站cpanel 子网站
  • 潍坊滨海开发区建设局网站小程序开发哪家好
  • 广东基层团组织建设部网站做网站 郑州公司有哪些
  • 新站如何让百度快速收录福州做网站的公司电话
  • 做网站公司怎么选南京网站南京网站开发
  • 青岛手机网站建设报价如何开跨境电商店铺
  • 西安电商网站建设期货做程序化回测的网站
  • 巩义网站建设公司如何说课网站建设
  • 一起做网店17zwdcom西安优化网站推广
  • 网站模板 介绍wordpress+系统安装
  • 百度做网站的费用阳泉推广型网站开发
  • 杭州建设主管部门的网站网站建设数据库代码
  • 做相册哪个网站好企业域名多少钱
  • 免费网站建设平台哪个好企业画册怎么设计
  • 济南网站建设公司晟创未来重庆h5建站模板
  • 郑州建站排名西安学校网站建设哪家好
  • 自适应网站设计尺寸城乡住房和城乡建设厅网站首页
  • 服务器上发布网站高端网站建设郑州
  • 深圳罗湖住房和建设局网站官网请问哪里可以做网站
  • 如何自己开一个网站中铁建门户网登录入口
  • 音乐网站排名wordpress前台不显示图片
  • 免费创立网站wordpress 文字弹窗
  • wordpress展示型外贸网站优化关键词可以选择哪个工具
  • 网站推广含义广告网络用语
  • iis7.5网站配置做阿里巴巴好还是网站好
  • 诸暨公司网站建设成品网站货源1688在线