iblog 5

苹果有iphone,我有iblog

导航

随笔分类 -  3-WPF

摘要:WPF窗口采用默认的Grid布局控件,其“Name”值为“grid1”,在“grid1”中添加三个Button按钮。动态添加控件并访问这些控件的代码如下: 1 private void button1_Click_1(object sender, RoutedEventArgs e) 2 { 3 //添加第一个文本框 4 TextBox tb1 = new TextBox(); 5 tb1.Name = "myTextBox1"; 6 7 tb1.Text = "第一... 阅读全文

posted @ 2014-04-02 18:10 cbtech 阅读(27827) 评论(0) 推荐(1)

摘要:xaml的发音为:zammel(英语音标),依据有二:依据一:下面一段话来自于国外英语教材《WPF Programmer's Reference》第xxvii页(PDF电子文稿的第29页)Many of these new concepts are uniied, elegant, and simple. Ideas such as declaratively building an interface in Extensible Markup Language (XAML — pronounced zammel), property value inheri-tance, and a 阅读全文

posted @ 2012-07-27 14:55 cbtech 阅读(5046) 评论(4) 推荐(0)

摘要:运行效果为:1、在项目中新建一个Lang文件夹用于保存我们的语言文件2、 在Lang文件夹中,新建"ResourceDictionary(WPF)",命名为"en-US.xaml",并将其BuildAction设置为Page,这是一个默认语言资源文件,其将被编译(而不是松散链接,这样可以确保在软件语言包丢失或没有某国家或地区的对应语言包时可以有一种默认的界面语言):我们这里采用英文作为默认语言:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/p 阅读全文

posted @ 2012-07-24 07:49 cbtech 阅读(2208) 评论(1) 推荐(1)

摘要:wpf100.com提供的wpf专题:http://www.wpf100.com/html/5/ 阅读全文

posted @ 2012-07-13 16:32 cbtech 阅读(252) 评论(0) 推荐(0)

摘要:效果图:前台代码: 1 <Window x:Class="Ch12Sample_03.Window4" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 Title="Window4" Height="307" Width="454" FontSize="14 阅读全文

posted @ 2012-07-10 17:23 cbtech 阅读(7739) 评论(2) 推荐(3)

摘要:链接:http://www.cnblogs.com/huangxincheng/ 阅读全文

posted @ 2012-07-04 17:47 cbtech 阅读(210) 评论(0) 推荐(0)

摘要:原因:DataGrid 的 EnableRowVirtualization 属性默认值是True,就是说动态加载数据,只实例化屏幕内可见的数据;行头的内容是通过绑定实现的,但是滚动刷新时传入的DataGridRow并不是实际位置的行,而是虚拟的,造成行头显示内容错乱;解决办法:方法1:设置EnableRowVirtualization=“False",简单易行,但系统资源的开销大方法2:http://blog.csdn.net/jickie/article/details/7088644。该方法未验证。 阅读全文

posted @ 2012-07-03 17:14 cbtech 阅读(1056) 评论(2) 推荐(1)

摘要:private void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e){ e.Row.Header = e.Row.GetIndex() + 1;}效果: 阅读全文

posted @ 2012-07-03 16:02 cbtech 阅读(313) 评论(0) 推荐(0)

摘要:运行界面:前台代码: <Grid> <DataGrid AutoGenerateColumns="True" Height="211" HorizontalAlignment="Left" Margin="27,34,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="334" IsReadOnly="True"> <DataGrid.Columns&g 阅读全文

posted @ 2012-07-03 15:59 cbtech 阅读(1219) 评论(0) 推荐(1)

摘要:前台代码:<Window x:Class="WpfApplication16.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:Wp 阅读全文

posted @ 2012-07-03 10:46 cbtech 阅读(1929) 评论(0) 推荐(0)

摘要:原文出处:http://www.bianceng.cn/Programming/net/201010/19512_2.htm为了使用 Personal 和 PersonalList,我们引入了一个 CLR Namespace。在主从结构 (Master-Detail) 显示中,我们通常要实现 "选择项跟踪" 功能,也就是说当我们选中主表的某个记录时,其他细节控件要同步刷新该记录的细节内容。<Window x:Class="Learn.WPF.Window1" xmlns="http://schemas.microsoft.com/winf 阅读全文

posted @ 2012-07-02 17:41 cbtech 阅读(1625) 评论(0) 推荐(0)

摘要:原文出处:http://www.im47.cn/?p=482ElementNameThe ElementName property is used to reference an object by the name of the object. This is particularly useful in XAML, where you can directly reference other elements defined in XAML. 举例<StackPanel Background=”Blue”><Button x:Name=”refButton” Backgr 阅读全文

posted @ 2012-07-02 17:20 cbtech 阅读(6607) 评论(0) 推荐(0)

摘要:原文出处:http://blog.csdn.net/sam1012/article/details/6690913ObjectDataProvider提供了绑定任意.net类型的功能,具体功能如下: 1.ObjectDataProvider提供了绑定任意CLR类型的公嫩那个。 2.它可以再XAML中利用生命史的语言以及参数化的构造函数完成对数据的创建 3.增加对成员函数的绑定 4.提供了更多的异步绑定的功能 下面用一个加法计算器来进行实例说明: 请先看我们的加法类: C#代码 namespaceBindingDemo { publicclassCalculator { pu... 阅读全文

posted @ 2012-07-02 16:40 cbtech 阅读(230) 评论(0) 推荐(0)

摘要:在项目中添加一个文件夹images ,在文件夹下添加一个tree.jpg的图片。在“解决方案资源管理器”中选择该图片,在属性窗口中将“复制到输出目录”选中“始终复制”,将“生成操作”选择为“内容”,这样,编译后,会在bin/debug目录下生成一个含有tree.jpg图片的名为images的文件夹。private void button1_Click(object sender, RoutedEventArgs e){ Uri uri = new Uri(@"images/tree.jpg", UriKind.Relative); ImageBrush ib = new I 阅读全文

posted @ 2012-07-02 16:18 cbtech 阅读(7872) 评论(0) 推荐(0)

摘要:Uri uri = new Uri(@"images/tree.jpg", UriKind.Relative);image1.Source = new BitmapImage(uri); 阅读全文

posted @ 2012-07-02 16:10 cbtech 阅读(3137) 评论(0) 推荐(0)

摘要:Color c = Color.FromRgb(200, 200, 200);SolidColorBrush s = new SolidColorBrush(c);this.Background = s; 阅读全文

posted @ 2012-07-02 15:52 cbtech 阅读(1465) 评论(0) 推荐(0)

摘要:原文出处:http://blog.csdn.net/sanjiawan/article/details/6785394前几天打算尝试下DataGrid的用法,起初以为应该很简单,可后来被各种使用方法和功能实现所折磨。网络上的解决方法太多,但也太杂。没法子,我只好硬着头皮阅览各种文献资料,然后不断的去尝试,总算小有成果。因此,把我学到的和大家分享一下,相信这篇文章会让你再很短的时间内学会DataGrid的大部分主要功能,而且很多难点都可以在里面找到解决方案。由于涉及的应用比较多,所以篇幅会很长。但可以确保各个版块相互独立,总共4个部分1.数据绑定2.DataGrid的增改删功能3.DataGri 阅读全文

posted @ 2012-07-01 22:16 cbtech 阅读(423) 评论(1) 推荐(0)

摘要:如果希望在多个项目之间共享资源,可以创建一个资源字典。资源字典是一个存储希望使用的资源的XAML文档。下面是一个资源字典的示例,Dictionary1.xaml:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib& 阅读全文

posted @ 2012-06-13 12:46 cbtech 阅读(258) 评论(0) 推荐(0)

摘要:当窗口关闭时,它会引发两个事件:Closing 和 Closed。Closing 在窗口关闭之前引发,它提供一种机制,可以通过这种机制来阻止窗口关闭。 系统会向Closing 事件处理程序传递一个 CancelEventArgs e,该参数实现 Boolean Cancel 属性,将该属性设置为 true 可以阻止窗口关闭。private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e){ MessageBoxResult result = MessageBox.Show("确定是退 阅读全文

posted @ 2012-06-13 12:44 cbtech 阅读(2617) 评论(0) 推荐(1)

摘要:原文链接:http://technet.microsoft.com/zh-cn/ms748948 阅读全文

posted @ 2012-06-13 12:44 cbtech 阅读(150) 评论(0) 推荐(0)