C#_Wpf_DataContex上下文整个类绑定
<Window x:Class="UserStore.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<!--g1绑定了Person-->
<Grid Name="g1">
<TextBox Height="23" Text="{Binding Name}" HorizontalAlignment="Left" Margin="50,22,0,0" Name="txtName" VerticalAlignment="Top" Width="155" />
<TextBox Height="23" Text="{Binding Age}" HorizontalAlignment="Left" Margin="50,70,0,0" Name="txtAge" VerticalAlignment="Top" Width="155" />
<TextBox Height="23" Text="{Binding Height}" HorizontalAlignment="Left" Margin="50,125,0,0" Name="txtHeight" VerticalAlignment="Top" Width="153" />
<CheckBox Content="性别" IsChecked="{Binding Gender}" Height="16" HorizontalAlignment="Left" Margin="50,178,0,0" Name="chkGender" VerticalAlignment="Top" />
</Grid>
</Window>
//MainWindow.xaml.cs
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.Navigation;
using System.Windows.Shapes; namespace UserStore
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private Person p1 = new Person(); public MainWindow()
{
InitializeComponent();
} private void Window_Loaded(object sender, RoutedEventArgs e)
{
p1.Name = "abc";
p1.Age = 26;
p1.Height = 170;
p1.Gender = true; g1.DataContext = p1; } }
}
//Person.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel; namespace UserStore
{
class Person
{
public int Age
{
get;
set;
}
public string Name
{
get;
set;
}
public int Height
{
get;
set;
}
public bool Gender
{
set;
get;
}
} }
C#_Wpf_DataContex上下文整个类绑定的更多相关文章
- jeecg中的一个上下文工具类获取request,session
通过调用其中的方法可以获取到request和session,调用方式如下: HttpServletRequest request = ContextHolderUtils.getRequest();H ...
- WPF Toolkit AutoCompleteBox 实体类绑定 关键字自定义关联搜索匹配
原文:WPF Toolkit AutoCompleteBox 实体类绑定 关键字自定义关联搜索匹配 WPF Toolkit AutoCompleteBox 实体类绑定 关键字自定义关联搜索匹配 网上的 ...
- [转]C#反射,根据反射将数据库查询数据和实体类绑定,并未实体类赋值
本文来自:http://www.cnblogs.com/mrchenzh/archive/2010/05/31/1747937.html /****************************** ...
- 时序图中的生命线与类绑定(EA)
使用时序图时序图( Sequence Diagram)时,有时候在起初拖放放的对象生命线未绑定相关的类. 如果: 但在后期需要和类进行绑定. 那么需要如下设置,右键你要关联的对象生命线,选择Advan ...
- Vuejs——(3)计算属性,样式和类绑定
版权声明:出处http://blog.csdn.net/qq20004604 目录(?)[+] 先上总结: (十九)标签和API总结(2) vm指new Vue获取的实例 ①当dom标签里的值 ...
- PYTHON-面向对象 类 绑定方法
面向对象三大特性(*****) 1继承 1. 什么是继承 继承是一种新建类的方式,新建的类称之为子类/派生类,被继承的类称之为父类/基类/超类 继承与现实生活中的继承一个意思 (例如 小明继承小明他爹 ...
- 如何将OpenCV中的Mat类绑定为OpenGL中的纹理
https://blog.csdn.net/TTTTzTTTT/article/details/53456324 如果要调用外接的USB摄像头获取图像通常使用OpenCV来调用,如何调用摄像头请参考本 ...
- Spring 上下文操作工具类 ContextUtils
ContextUtils.java package com.java.config; import org.springframework.beans.BeansException; import o ...
- java上下文Context类
Context在Java中的出现是如此频繁,但其中文翻译"上下文"又是如此诡异拗口,因此导致很多人不是很了解Context的具体含义是指什么,所以很有必要来深究一下这词的含义. 先 ...
随机推荐
- AngularJS with MVC4 CRUD
CRUD using MVC Web API and AngularJS In this article I am going to demonstrate about how can we crea ...
- C#日期时间格式化
日期转化一为了达到不同的显示效果有时,我们需要对时间进行转化,默认格式为:2007-01-03 14:33:34 ,要转化为其他格式,要用到DateTime.ToString的方法(String, I ...
- ASP.NET MVC 入门10、Action Filter 与 内置的Filter实现(实例-防盗链)
于ASP.NET MVC Preview5. 前一篇中我们已经了解了Action Filter 与 内置的Filter实现,现在我们就来写一个实例.就写一个防盗链的Filter吧. 首先继承自Filt ...
- C# 中的结构类型(struct)
原文 C# 中的结构类型(struct) 简介 有时候,类中只包含极少的数据,因为管理堆而造成的开销显得极不合算.这种情况下,更好的做法是使用结构(struct)类型.由于 struct 是值类型,是 ...
- [转] Envelop
xiaohaidepoli原文Envelop Envelope也称包络线,是一个矩形区域,是每个几何形体的最小外接矩形.每个Geometry都拥有一个Envelope,包括Envelope自身. 它定 ...
- 27、Service
1服务可以通过startservice的方法 开启.通过stopservice的方法 停止. 服务有一个特点: 只会一次onCreate()方法一旦被创建出来,以后oncreate() 就不会再被执行 ...
- [Irving]SqlServer 标量函数 详解【转】
--创建用户定义函数.这是一个已保存 Transact-SQL 或公共语言运行时 (CLR) 例程,--该例程可返回一个值.用户定义函数不能用于执行修改数据库状态的操作.--与系统函数一样,用户定义函 ...
- 【暑假】[实用数据结构]UVAlive 4670 Dominating Patterns
UVAlive 4670 Dominating Patterns 题目: Dominating Patterns Time Limit: 3000MS Memory Limit: Unkn ...
- ffmpeg常见命令
一.安装 下载ffmpeg,解压之后配置环境变量即为安装 打开dos界面,进入目标文件夹例如:E:/ cd E:\BaiduYunDownload\ffmpeg\ffmpeg_simple ...
- 数电课设——琐碎
这几天没有更新过网站了,也没继续开发VellLock了,可是感觉还是没有闲着,一直在跟下面的一些元器件在打交道,当然下面的都是小儿科,英文文档都看得我快吐血了.数电基本属于棺材边上过的我,是各种头大, ...