• dataTemplate 的使用之listView


    <Window x:Class="WpfApplication1.Window39"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:System.Collections;assembly=mscorlib"
    xmlns:local="clr-namespace:WpfApplication1"
    Title="Window39" Height="250" Width="428.7">
    <Window.Resources>
    <!--数据集合-->
    <c:ArrayList x:Key="stuList">
    <local:Student39 Id="1" Name="Timoty Liu" Skill="WPF" HasJob="True"></local:Student39>
    <local:Student39 Id="2" Name="Tom Chang" Skill="BI/SQL" HasJob="True"></local:Student39>
    <local:Student39 Id="3" Name="Guan Chong" Skill="Writing" HasJob="False"></local:Student39>
    <local:Student39 Id="4" Name="Shanshan" Skill="C#/Java" HasJob="False"></local:Student39>
    <local:Student39 Id="5" Name="Pingping Zhang" Skill="Writing" HasJob="False"></local:Student39>
    <local:Student39 Id="6" Name="kenny Tian" Skill="Asp.net" HasJob="False"></local:Student39>
    </c:ArrayList>
    <!--DataTemplate-->
    <DataTemplate x:Key="nameDT">
    <TextBox x:Name="txtBoxName" Text="{Binding Name}" GotFocus="txtBoxName_GotFocus"></TextBox>
    </DataTemplate>
    <DataTemplate x:Key="skillDT">
    <TextBox x:Name="txtSkill" Text="{Binding Skill}"></TextBox>
    </DataTemplate>
    <DataTemplate x:Key="hasJobDT">
    <CheckBox IsChecked="{Binding HasJob}" x:Name="checkBoxJob"></CheckBox>
    </DataTemplate>
    </Window.Resources>
    <Grid Margin="5">
    <ListView x:Name="lvStudent" ItemsSource="{StaticResource stuList}">
    <ListView.View>
    <GridView>
    <GridViewColumn Header="ID" DisplayMemberBinding="{Binding Id}"></GridViewColumn>
    <GridViewColumn Header="姓名" CellTemplate="{StaticResource nameDT}"></GridViewColumn>
    <GridViewColumn Header="技术" CellTemplate="{StaticResource skillDT}"></GridViewColumn>
    <GridViewColumn Header="已工作" CellTemplate="{StaticResource hasJobDT}"></GridViewColumn>
    </GridView>
    </ListView.View>
    </ListView>
    </Grid>
    </Window>

  • 相关阅读:
    从零开始学Flask框架-002
    从零开始学Flask框架-001
    js 数组去重 + 数组内元素为对象去重
    使用npx 搭建项目-继续爬坑
    使用nuxt.js+koa2创建项目-继续爬坑
    nuxt.js 初次运行报错 -- 爬坑全过程
    VueRouter配置引入
    MySqlHelper.ExecuteReader 爬坑
    javascript 解析,设置,检测cookie
    python sqlite数据库操作小坑
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14152381.html
Copyright © 2020-2023  润新知