• 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"); } } }
  • 相关阅读:
    js 整站模式窗口打开
    WebDev.WebServer 学习
    AjaxPro.2.dll基本使用
    jQuery.get(url,[data],[callback])
    ASP.NET CheckBoxList复选框
    Win7开发系列: windows服务操作基础
    .NET Remoting开发系列:(三) Remoting服务发布方式
    mysql 视图操作和存储过程
    Flash Lite1.1错误代码表
    myeclipse svn 清除缓存用户和密码
  • 原文地址:https://www.cnblogs.com/w-wz/p/4607052.html
Copyright © 2020-2023  润新知