WPF——ListBox创建并连接后台数据,并实现数据驱动实施更新UI界面

本文介绍了如何在WPF中创建ListBox并连接后台数据,利用数据驱动技术实现实时更新用户界面。通过在XAML中构建UI,并在CS中定义继承INotifyPropertyChanged接口的Employee类,创建ObservableCollection< Employee >来观测数据变化,从而自动更新ListBox显示。
摘要由CSDN通过智能技术生成

对如何通过WPF来创建一个listBox,并同后台数据链接,实现数据驱动实施更新UI界面,做一个简单的样例介绍。(简陋的UI和一塌糊涂的命名还请大家见谅)

在这里插入图片描述

首先现在XAML中创建UI如下图。

<Window x:Class="listBox.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:listBox"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">

    <Grid Margin="5">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*"/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>
        <TextBlock Text="请输入学生ID:" Grid.Row="1" Grid.Column="0"/>
        <TextBox Name="STUid" Grid.Row="0" Grid.Column="0"/>
        
        <TextBlock Text="请输入学生姓名:" Grid.Row="3" Grid.Column="0"
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值