随笔分类 - [BOOK]Pro WPF in C# 2010
摘要:1 <Window x:Class="RoutedEvents.TunneledKeyPress" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 Title="TunneledKeyPress" Height="411" Width="403" 5 PreviewK
阅读全文
摘要:假设StackPanel包装了一些按钮,并且希望一个事件中处理程序中所有这些按钮的单击事件。粗略的方法是将每个按钮的Click事件关联到同一个事件处理程序。但是Click支持事件冒泡,从而提供了一个更好的选择。可以通过更高层次元素的Click事件(如StackPanel面板)来处理所有按钮的单击事件。 1 <Window x:Class="Page111.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="ht
阅读全文
摘要:<Window x:Class="LayoutPanels_InkCanvas.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"> <InkCanvas Na
阅读全文
摘要:<Window x:Class="LayoutPanels.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"> <Grid ShowGridLines=&qu
阅读全文
摘要:一般的分割代码<Window x:Class="SharedSizeGroup.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"> <Grid> <
阅读全文
摘要:不应显示设定元素(比如控件)的尺寸。不应使用屏幕坐标指定元素的位置。布局容器和它们的子元素“共享”可以使用的空间。可以嵌套布局容器。布局过程:(包含2个阶段)测量阶段:容器遍历所有子元素,并询问子元素所期望的尺寸。排列阶段:容器在合适的位置放置子元素。
阅读全文
摘要:当编译WPF应用程序时,Visual Studio有两个阶段的编译处理过程:(1)将XAML编译成BAML(2)用选择的语言为窗口创建一个部分类(Window1.g.cs形式)部分类包含三部分内容:(1)窗口中所有控件的字段(Name已赋值的控件会生成对应字段)(2)当构造函数调用InitializeComponent()方法时,从程序集中加载BAML的代码来创建对象树。(3)void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)函数代码负责将恰当的控件对象指定到各个字段以及
阅读全文
摘要:复杂属性:(属性元素语法)Parent.PropertyName标记扩展:<Button... Foreground="{x:Static SystemColors.ActiveCaptionBrush}"><Button ...> <Button.Foreground> <x:Static Member="SystemColors.ActiveCaptionBrush"></x:Static> </Button.Foreground></Button>附加属性:<
阅读全文
摘要:只用代码创建WPF应用:1、VS2010新建|Visual C#|Windows窗体应用程序;名称(NonCompiledXaml)2、Solution Explorer中删除Form1.cs组3、新建项Visual C#|类;名称(Window1)4、Window1.cs的代码using System.Windows;using System.Windows.Controls;using System.Windows.Markup;using System.Drawing;using System.Windows.Media;public class Window1 : Window{ ..
阅读全文

浙公网安备 33010602011771号