zoukankan      html  css  js  c++  java
  • wpf 数据绑定 联系

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.ComponentModel;
    
    变量:
    namespace 联系 { public class DA:INotifyPropertyChanged { private string _Name; public string Name { get { return _Name; } set { _Name = value; OnPropertyChanged("Name"); } } private string _Pwd;
    public string Pwd { get { return _Pwd; } set { _Pwd = value; OnPropertyChanged("Pwd"); } } public event PropertyChangedEventHandler PropertyChanged;// public virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } }
    表里添加:
    <Window x:Class="联系.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <Label Content="显示" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,26,0,0"/> <TextBox Name="aaa" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="{Binding Name}" VerticalAlignment="Top" Width="120" Margin="103,29,0,0"/> <TextBox HorizontalAlignment="Left" Height="23" Margin="103,97,0,0" Text="{Binding Text, ElementName=aaa}" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/> <Button Content="确定" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="103,150,0,0" Click="Button_Click_1"/> </Grid> </Window>
    方法:
    using
    System; using System.Collections.Generic; using System.Linq; using System.Text; 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.Shapes; namespace 联系 { /// <summary> /// Window1.xaml 的交互逻辑 /// </summary> public partial class Window1 : Window { DA da; public Window1() { InitializeComponent(); da = new DA() { Name="admin",Pwd="123"}; this.DataContext = da; } private void Button_Click_1(object sender, RoutedEventArgs e) { da.Name = DateTime.Now.ToString("HH:mm:ss:fff"); } } }
  • 相关阅读:
    安装GitLab出现ruby_block[supervise_redis_sleep] action run
    docker tag根据镜像id做标签,用于应用的回滚
    Jenkenis报错:该jenkins实例似乎已离线
    kubernetes-批量删除Evicted Pods
    阿里云k8s构建镜像时设置版本号用于版本回滚
    Java虚拟机6:内存溢出和内存泄露、并行和并发、Minor GC和Full GC、Client模式和Server模式的区别
    Java虚拟机5:Java垃圾回收(GC)机制详解
    Java虚拟机4:内存溢出
    Java虚拟机3:常用JVM命令参数
    Java虚拟机2:Java内存区域及对象
  • 原文地址:https://www.cnblogs.com/w-wz/p/4607052.html
Copyright © 2011-2022 走看看