- 博客(52)
- 资源 (2)
- 收藏
- 关注
翻译 WPF Command 案例
实现这一一个需求:定义一个命令,使用Button来发送命令,当命令送达TextBox时TextBox会被清空,若TextBox中没有文字则命令不可被发送。前端: 后台: public partial class Window1 : Window { private RoutedCommand rcmd
2015-03-27 16:25:17
592
翻译 路由事件——附加事件案例
1,前端: 2,后台: public partial class AttachedEventDemo : Window { Student stu = new Student() { Name = "Tim" }; public AttachedEventDemo() {
2015-03-20 17:32:10
598
翻译 路由事件中级案例
前端: 后台: public partial class Window2 : Window { public Window2() { Initia
2015-03-20 15:57:14
432
翻译 路由事件初级案例
前端: 后台: public partial class MainWindow : Window { public MainWindo
2015-03-20 15:53:16
423
翻译 附加属性案例
附加属性: 例如一个TextBox,它可能被放在一个Grid中,也可能被放在一个Canvas、StackPanel中,但文本框的设计者不可能知道控件发布后程序员是把它放在Grid里还是Canvas里,所以他也不可能为TextBox准备诸如Column、Row或者Left、Top这类属性,那么干脆让布局来决定一个TextBox用什么属性设置其位置吧! 附加属性的本质就是依赖属性;
2015-03-20 10:28:08
635
翻译 依赖属性实验案例一
目的:通过一个Student对象,实现前端两个TextBox输入值相同(此案例仅做实验,用于理解最简单的依赖属性用法,实际中不会这样用)前端: 后台: public partial class MainWindow : Window { Studen
2015-03-19 17:33:21
569
翻译 Binding之MultiBinding
本例实现:第一二个TextBox输入内容一致,第二三个TextBox输入内容一致时,Button被启用.前端: 后台: public partial class MultiBindingDemo : Window
2015-03-19 14:49:45
596
翻译 Binding-Validation
Binding对数据的转换和校验案例:前端:<Window x:Class="Demo.ValidationRuleDemo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/x
2015-03-19 11:55:33
452
翻译 Binding之RelativeSource
有时我们不能确定作为Source的对象叫什么名字,但知道它与作为Binding目标的对象在UI布局上有相对关系,比如控件自己关联自己的某个数据、某级容器的数据。这时就可以用RelativeSource。前端:<Window x:Class="Demo.RelativeSrcDemo" xmlns="http://schemas.microsoft.com/winfx/200
2015-03-19 10:47:33
470
翻译 ObjectDataProvider 作为Binding的Source来使用的案例
ObjectDataProvider 作为Binding的Source来使用的案例:前端:<Window x:Class="Demo.ObjDataProviderDemo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.mi
2015-03-18 17:32:34
494
翻译 ObjectDataProvider使用简单案例
前端:<Window x:Class="Demo.ObjDataProviderDemo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Ob
2015-03-18 16:42:15
1691
翻译 使用Linq检索结果作为绑定源
本例介绍通过Linq检索三种重要绑定来源:Model: public class AStudent { public string Alias { get; set; } public string StuName { ge
2015-03-17 13:52:11
432
翻译 WPF中TreeView和Xml的结合使用案例
前端代码:<Window x:Class="Demo.Xml621" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Xml621" Hei
2015-03-17 10:34:55
4754
原创 WPF Binding相关的一些常见方式总结(八)
列表控件绑定到集合:前端:<Window x:Class="Demo.Window3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s
2015-03-06 16:49:53
806
原创 WPF Binding相关的一些常见方式总结(七)
没有Source的Binding, 使用DataContext作绑定源;(实现与案例A一样的功能):前端: Model:public class Student : INotifyPropertyChanged { private string stuNa
2015-03-06 16:45:28
540
原创 WPF Binding相关的一些常见方式总结(六)
前端资源绑定的几种典型方式:<Window x:Class="Demo.Window3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sy
2015-03-06 16:44:51
546
翻译 WPF Binding相关的一些常见方式总结(五)
集合绑定初级:前端: 后端: public Window3() { InitializeComponent(); List stringList = new List() { "tom", "lucy"
2015-03-06 16:13:04
503
原创 WPF Binding相关的一些常见方式总结(四)
将一个文本框中文本长度绑定给另一个文本框显示: //注意,这里的Mode要选OneWay. 改为后台实现就是:tbx2.SetBinding(TextBox.TextProperty, new Binding("Text.Length") {Mode=BindingMode.OneWay
2015-03-06 16:10:13
539
原创 WPF Binding相关的一些常见方式总结(三)
控件之间的互相绑定: 换种方式在后台实现,以上代码相当于: --> public partial class Window1 : Window {
2015-03-06 16:08:04
457
原创 WPF Binding相关的一些常见方式总结(二)
由于许多类似TextBox的UI元素的基类FrameworkElement对BindingOperation.SetBinding(...)进行了封装,所以案例A中的Binding部分可以从:Binding bd = new Binding(); bd.Source = myStu; bd.Path = new PropertyPath("Stu
2015-03-06 16:05:25
416
原创 WPF Binding相关的一些常见方式总结(一)
Model: public class Student : INotifyPropertyChanged { private string stuName; public string StuName { get { return stuName; } set { stuName = value; if (PropertyChanged != null) { this.PropertyChange
2015-03-06 15:55:54
623
转载 编码速度之——文本选中、光标移动...
+Spacebar 创建不间断空格 Ctrl+连字符 创建不间断连字符 Ctrl+B 使字符变为粗体 Ctrl+I 使字符变为斜体 Ctrl+U 为字符添加下划线 Ctrl+Shift+< 缩小字号 Ctrl+Shift+> 增大字号 Ctrl+Q 删除段落格式 Ctrl+Spacebar 删除字符格式 Ctrl+C 复制所选文本或对象 Ctrl+X 剪切所选文本或对象 Ct
2012-09-01 22:33:11
884
原创 我对委托、事件委托的一点理解
//1.声明关于事件的委托; public delegate void AlarmEventHandler(object sender, EventArgs e);以上,声明一个委托, 类似C语言中声明一个函数指针的类型, 这个类型说明了 由它去声明的指针 所指向的函数 的参数类型和返回类型。//2.声明事件(委托); public event AlarmEven
2012-08-31 09:53:31
421
原创 TextureBrush画刷 重复显示问题(图像便宜问题)
近来用TextureBrush画一个背景, 把坐标改为非(0,0)的情况时, 以原大小显示的时候总是出现偏移, 以更大的尺寸显示时, 会出现无数个图片。 后来找到了解决方案:TextureBrush br = new TextureBrush( logo );详细参考:http://blog.youkuaiyun.com/tjvictor/article/details/758331
2012-08-03 14:28:43
964
原创 Winform画背景图片的两种方法TextureBrush与Graphics.DrawImage()
1, 使用drawImage的例子:private void DrawImage(Graphics g) { if (backImg == null) return; else this.Size = backImg.Size; Rectang
2012-08-01 10:38:01
5834
原创 c# .Net 根据资源文件名获取资源文件对象
string imageName; public string ImageName { get { return imageName; } set { imageName = value; this.BackgroundIma
2012-07-30 15:33:39
4078
原创 Cannot modify the return value of 'System...ClientRectangle' because it is not a variable
最近做一个换肤的程序, 在修改窗体的ClientRectangle.Height值的时候出现了题目这样的错误。 后来发现,把鼠标放到ClientRectangle.Height的Height上时, 显示可以进行Get和Set但 ClientRectangle本身的定义里面只支持Get操作, 而没有Set操作, 它不是一个变量, 是Control类的一个公共属性。然后发现Control类
2012-07-28 09:11:55
1050
原创 Visual studio最常用热键(快捷键)hottest_keys_set
查找某关键字所有引用: shift+F12显示属性窗口:F4打开解决方案资源管理器: Ctrl+Alt+L打开工具箱: Ctrl+Alt+X导航到上一个操作页面处: Ctrl + 减号导航到下一个操作页面处: Ctrl + Shift + 减号添加现有项: Alt + Shift + A添加新项: Ctrl + Shift + A格式化选中代码: Ctrl + K
2012-07-27 18:59:58
404
原创 设计器是如何确定哪些属性会在Designer.cs中生成的?
之所以要解决这个问题, 是因为, 我的自定义组件代码是这样写的:private int _radius;public int Radius{ get { return this._radius; } set { this._radius = value; }}Radius值我将在构造函数里面, 从资源文件中获取,同时, 我想_radius的值也就有了。当我把自
2012-07-27 18:49:29
1361
转载 ColorBlend学习
From:http://blog.youkuaiyun.com/yglbj/article/details/5654792using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;us
2012-07-26 11:49:10
2809
原创 winform拖拽自定义用户控件到设计器时报错, 而运行无错的情况
最近在做一个Winform软件的换肤部分功能, 主要就是在各个控件的Paint事件中加入相应的加载资源文件的代码。出现错误较为频繁的一个点是, 代码写好了, 运行没问题,一旦将自定义控件拖拽到设计器中就报错。最终解决的办法是,在代码中判断component.designmode这个变量的状态, 如果为true则说明处于设计模式, 则不执行paint部分代码;反之处于运行状态, 就进行喷绘。
2012-07-23 13:54:50
4460
原创 在一个项目中明明引用了某工程, 在引用时也能智能地提示,但编译时却提示没有using引用
检查各工程的属性中目标框架一项, 确保都相同。比如, 我原本的几个工程都是用的.Net framework4.0, 而新来的一个工程使用.netFramework 3.5或者.net framework 4.0 client profile.就会产生题目中的错误。参考:http://cnn237111.blog.51cto.com/2359144/630861
2012-07-18 16:09:17
753
转载 iframe
<iframe width="600px" scrolling="no" height="520px" frameborder="0" noresize="noresize" src="javascript:'\nJS1k, 1k demo submission [1022]var b = document.body;var c = document.getElementsB
2012-07-06 20:50:15
333
转载 html标签自定义属性的应用
HTML标签可以自定义属性,但是我们要考虑其在IE、Firefox以及chrome下的兼容性问题。例如:复制代码这里的“myAttr”就是这个标签的自定义属性了。如果定义了属性却使用不了,那么这个属性就没有任何意义了,接下来就是如何去调用我们的自定义属性的值了。在IE浏览器里,我们通过获取对象后直接调用就可以了document.g
2012-06-28 10:58:19
802
转载 JS实现可编辑的表格(转)
from:http://apps.hi.baidu.com/share/detail/30648462GridEdit.js/** * JS实现可编辑的表格 * 用法:EditTables(tb1,tb2,tb2,......); * Create by Senty at 2008-04-12**///设置多个表格可编辑function EditTables() { fo
2012-06-27 15:58:17
15303
7
原创 Sql server数据库.mdf文件不能拷贝, 重启还是提示其它程序在用
解决方案: 在服务里将Sql Server(MSSQLSERVER)停掉。拷出来后再将其开启
2012-06-21 14:34:37
3025
高级软件工程(Higher software engineering)
2009-08-30
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人