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的具体含义是指什么,所以很有必要来深究一下这词的含义. 先 ...
随机推荐
- 安装ejabberd2并配置MySQL为其数据库
以前用过openfire做为服务器,但是openfire的集群支持不是很好,所以改用Ejabberd,由于它是用Erlang语言开发的,其并发率与分布式的功能都是很强悍的,在此我记录一下我的安装与配置 ...
- Hibernate4.x之Session--常用方法
接上篇文章继续学习Hibernate的Session(http://www.cnblogs.com/dreamfree/p/4111777.html) 持久化对象的状态; 站在持久化的角度,Hiber ...
- HDU 1405 The Last Practice
The Last Practice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 导入showb时候出错--2015-12-4
[root@cache-02 ~]# /opt/coreseek/csftweb-bash: /opt/coreseek/csftweb: is a directory[root@cache-02 ~ ...
- [LeetCode]LRU Cache有个问题,求大神解答【已解决】
题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the ...
- 自己常用的js方法
$(function(){ tabview("#zcfw_list1"); tabview("#zcfw_list2"); tabview("#zcf ...
- [读书笔记]了不起的node.js(二)
这周做项目做得比较散(应该说一直都是这样),总结就依据不同情境双开吧-这篇记录的是关于node的学习总结,而下一篇是做项目学到的web前端的知识. 1.HTTP篇 node的HTTP模块在第一篇时接触 ...
- Java网络编程(TCP客户端)
TCP传输:两个端点建立连接后会有一个传输数据的通道,这个通道就称为流,而且是建立在网络基础上的流,之为socket流,该流中既可以读取也可以写入. TCP的两个端点:一个客户端:ServerSock ...
- C/S 和 B/S 模式的区别与联系
如果要比较两种事物之间的相同点和不同点,首先,我们要分别对这两种事物有一个最基本的了解. 一.C/S与B/S的定义 C/S (Client/Server)结构,即大家熟知的客户机和服务器结构.它是软件 ...
- Resharp非常实用的快捷键
Alt+Home 定位到父类.父接口 Alt + End 定位到子类 Ctrl+T 快速在整个解决方案下搜索 类型.方法.文件夹 Alt+Ctrl+Spance 给出提示框 Shift+F ...