WPF 你真的会写 XAML 吗?浅谈 ControlTemplate 、DataTemplate 和其它 Template
本文希望从写死的代码慢慢引入 WPF 的一些机制。
一、Button 难题
我们想要修改 Button 的背景色但是效果非常不理想,默认的 Button 样式是完全无法给各人看的,改造 Button 的方法是借助 Style 在 Template 中自界说 ControlTemplate(Style 并不关键)。- [/code][indent]Style 在自界说控件的部分并不关键,实际上你完全可以利用 Button.Template 属性展开然后实现同样的效果,但是缺少复用性。
- [/indent][size=5]二、猿之手/猴爪难题与依赖属性[/size]
- 固然它现在变得比较好看了,但是这个 Button 样式完满是一个植物人,成了一个赛博手办,好看固然是好看,甚至是可以执行 Click 事件来进行交互的,但是我们本来可以设置 不能用了。
- 之以是不能用,原因是由于你在 ControlTemplate 的地方确实没有让 Button 的 Background 发挥作用。
- 这种活动就好像下面的代码一样:
- [code]private void SayHello(string name)
- {
- <Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>Console.WriteLine("hello, world!");
- }
复制代码 请问,在这个代码片段,一个名为 SayHello 的函数中,参数 name 的意义是什么?
为此,WPF 引入了依赖属性 DependencyProperty 的机制来让它就像函数的参数意义,可以或许为 ControlTemplate 里面的东西带来意义。
在 WPF 的控件中,大部分属性都属于依赖属性,对于 Button 来说,Background 是依赖属性,Content 也是。
我们是必不可少要学习自己创建自界说控件和自界说的依赖属性的,但是在这一部分,我们来看一下如何利用自带的依赖属性为原生控件进行自界说。- [/code]总而言之,利用 {TemplateBinding XXX} 对控件的依赖属性进利用用,有的时间直接利用 TemplateBinding 可能无法生效,以是你可以利用下面的平替,下面这种的泛用性会更强,但是没有 TemplateBinding 的写法那么方便,属于是比较 Hack 的写法,我们在后面的介绍中有一处只有它才气实现的效果。
- [code]
复制代码 三、更好看的样子
当你知道了 Background 和 Content 都是依赖属性之后,我们目前没有做 TextBlock 出现内容的参数化模板绑定,但是我想你也应该知道怎么做了。
你在进行编写的时间,可能会碰到智能提示的问题,你会发现你在为 TextBlock 的 Text 进行绑定的时间,可能会发现你在 VS 的智能提示的小窗里并没有办法找到 Content,这并不是 VS 出现了 BUG,VS 的消极反应也并不是在否定你,我们打算在美化完 UI 后,再来细讲为什么 VS 会如此的不共同,为什么在 TextBlock 的 Text 中绑定 Content 是一个不算对也不算错的活动。四、我们的 IDE 到底在抗拒什么,会不共同我们的 XAML 编写?
在 VS 的 WPF 编辑情况中对于 控件模板 ControlTemplate 和 控件绑定的智能提示来自于 TargetType="Button" 这边对控件的指定,如果没有指定类型,智能提示会完全没有办法给你补全什么有用代码。
我们在写 Background 的时间很顺利但是在 写 Text 的时间碰到了 VS 的阻挠,即便如此我们硬写照旧写出来了。
效果还不错是吧?
你知道吗,WPF 的很多控件是支持嵌套的,就像下面这样:
代码就像这样:- <Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 你会发现你无法为它再赋予 Content 了,编辑器会告诉你属性重复,也就是说,你在 xaml 里面写的 Text 属性为"hello, world!" 的文本块 TextBlock 控件,已经是 Button 的 Content 属性了。
以是,我想要说什么?
Content 这个依赖属性能描述的不但是一个字符串,它实际上能描述一个对象,它的类型实在是 object,我们去看它的界说就可以知道:- public object Content { get; set; }
复制代码 正是由于 Content 是 object 类型,而 Text 属性吸收的要求是 string 字符串,以是 VS 在智能提示的时间并不认为它们俩符合,以是我们在智能提示的时间根本找不到它。
那,为什么我们直接写照旧可以或许生效?
对于 Text 这种字符串类型来说,我们恰恰传的是 string 字符串这个对象,瞎猫碰上死耗子,自然就没有发现问题。
以是,如果我们的自界说样式有内部嵌套的对象,它在利用 TemplateBinding 写法的我们的样式里,是完全没有反应的。
如果说你真的要让只能吸收到 string 的 Text 依赖属性,被迫吃下那么一坨,不就是 object 吗,只要是个 object ,利用 ToString() 转成字符串不就好了么。于是,你可以利用上文提到的那种非常冗长的写法。
于是就会有这样的效果:
- [/code][code]<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 五、真正的 Button
为了实现 Button 内部控件的嵌套和对象的嵌套出现,用我们目前的 TextBlock 来出现内容是完全不可取的。
实际上一个标准的 Button 实现会利用 ContentPresenter 来出现,ContentPresenter 本身具备的 Content 依赖属性才是 Button 的 Content 的依赖属性最终的去处。- [/code]这个样式的效果是这样的:
- [align=center][img]https://img2024.cnblogs.com/blog/2411090/202503/2411090-20250321115144483-438595568.png[/img][/align]
- 代码:
- [code]<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 六、Content object 的样子
1. 若我掏出自界说对象,你该如何应对?
我们现在能知道的是,对于字符串类型的 Content 会显示一串文字,如果填入的是控件内容,它会显示控件 UI 的样子,用来为按钮创建图标等相干需求的时间会非常有用。
可是,object 也就意味着是所有类型,我们自己的 class 实例对象给它会是什么样子?
让我们在 Button 初始化的时间在 C# Code-Behind 代码的部分创建一些内容吧!
这是我们自界说的类:- public class Person{<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>public string Name { get; set; }<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>public int Age { get; set; }}
复制代码 请注意 xaml 中关于 Loaded="Button_Loaded" 的部分。- [/code]这是事件订阅后要执行的事情。
- [code]private void Button_Loaded(object sender, RoutedEventArgs e){<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>var button = sender as Button;<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>if (button is null) return;<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>// 固然可以写成 button!.Content 但是怕各位看不懂<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>button.Content = new Person() { Name = "小明", Age = 18 };}
复制代码 这是效果:

由于我们的项目叫做 WPFPlayground,以是 Person 这个对象被 ToString()后得到的结果是 WPFPlayground.Person 由于尺寸有限以是目前出现的是这样。
我们希望把信息显示出来,你可以这样完善 Person 的内容:- public class Person{<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>public string Name { get; set; }<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>public int Age { get; set; }<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>public override string ToString()<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>{<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>return $"{Name}: {Age} !!!!!";<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>}}
复制代码 效果就会变成这样:

2. 若我想要给这个数据自界说表面,你又该如何应对?
但是有的时间,我们希望出现的数据也是有布局和 UI 的。
由于自界说数据的属性并不是依赖属性,以是上面在控件模板中介绍的那些方法,TemplateBinding 之类的做法在这边就完全失效了。
面对这个数据的表面界说,你要利用 ContentTemplate 来做。
当然,ContentTemplate 内容模板和 ControlTemplate 控件模板长得很像,但是不一样的概念,ContentTemplate 和 Content 是一对内容,相互共同才气实现最好的效果,作为 Content 的好兄弟,ContentTemplate 自然也是依赖属性,在 ContentPresenter 中发挥作用。
我们说了这么多话,到底想要说什么?
我想说的是,光写 Button 中的 ContentTemplate 是没有用的,由于实际负担工作的是 你的 ControlTemplate 控件模板的 ContentPresenter,你需要把这个依赖属性作为参数传递进去,写成这个样子:- [/code]然后,我们将开始面对 DataTemplate 了。
- 我们为 Button 在更新了 Style 后,编写了对应的 ContentTemplate。
- ContentTemplate 的类型是 DataTemplate,集合容器所采用的 ItemTemplate 类型也是 DataTemplate 实在也是 DataTemplate,由于此中的原理实在就是每一项套了一个 ContentPresenter 内容出现器。
- [code]<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 会变成这样的效果:

于是,在控件和主题上,你可以为 ControlTemplate 方面打一个坚实的底子用于项目风格的复用,而在自界说数据特别是业务数据的出现上,以 ContentTemplate 为代表的 DataTemplate,会为你带来业务上的拓展性。
七、所谓集合面板 ItemsControl、ListBox
1. 每一项的表面样子利用 ItemTemplate 界说
我们来创建一个毫无关照能力,只是好看的 ViewModel,并不实现 INotifyPropertyChanged。- public class MainViewModel{<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>public List Persons { get; set; }<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>public MainViewModel()<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>{<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>Persons = new List()<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>{<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>new Person(){ Name = "小明", Age = 18},<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>new Person(){ Name = "小红", Age = 17},<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>new Person(){ Name = "小黄", Age = 16},<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>new Person(){ Name = "小亮", Age = 11},<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>new Person(){ Name = "小军", Age = 19},<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>new Person(){ Name = "小帅", Age = 30},<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>new Person(){ Name = "小马", Age = 6},<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>};<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>}}
复制代码 我相信你知道怎么绑定上下文,以是这边只做了绑定的部分:- [/code]我们来看一下效果:
- [align=center][img]https://img2024.cnblogs.com/blog/2411090/202503/2411090-20250321115202306-911974216.png[/img][/align]
- 你可以注意到的是,集合容器控件中出现的样子,和我们刚才描述的关于 ContentPresenter 和 Content 的机制是完全一致的。
- 让我们把上面写的 ContentTemplate 中的 DataTemplate 交给 ItemsControl 的 ItemTemplate 中去。
- [code]<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 现在的效果就是这样的:

具体 ItemTemplate 生效的原因来自于 ContentPresenter,参看源码:https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Controls/ItemsControl.cs,a32a4ab17d3998f0,references
2. 容器的表面
你可能会对 ItemsControl 和 ListBox 的默认的 StackPanel 纵向布局感到不满。
这个时间你可以利用 ItemsPanel 创建 ItemsPanelTemplate 对象,它是属于 ControlTemplate 相似的,和数据无关的 Template。
默认情况如果写出来是这样的:- <Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 我如果在利用它,一般我会利用它的 WrapPanel 和 Horizontal StackPanel。
2.1 WrapPanel 效果
效果:
WrapPanel 的可折叠性。

代码:- <Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 2.2
效果:

代码:- <Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 八、所谓 DataGrid 和 CellTemplate
这是 DataGrid 的默认样子:- [/code]除了显示一些栏位字段属性之外,你可能希望能本来的数据源中显示一些别的控件,比如我们上面界说的 DataTemplate,来帮助我们更加可视化的看到数据。
- 你可以实现这样的效果:
- [align=center][img]https://img2024.cnblogs.com/blog/2411090/202503/2411090-20250321115221487-810875909.png[/img][/align]
- 代码如下:
- [code]<Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button><Button Width="100" Height="100">
- <Button
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Width="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Height="100"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>Background="LightGreen"
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button>>
- <Button
- Width="100"
- Height="100"
- Background="LightGreen"
- >
- <TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Name="PART_TextBlock" Text="hello, world!" />
- </Button><TextBlock Text="hello, world!" />
- </Button>
复制代码 推荐用法:可以用来显示重要程度比如红色绿色、进度百分比等等效果,具体想要可视化什么取决于业务需求。
九、总结
属性名类型用法TemplateControlTemplate在 Control 控件中的 Template 属性,是 WPF 最为底子的内容,是所有控件的可复用性的保障,通常和 Style 搭配,编写 ControlTemplate 就好比在 xaml 中编写函数一样,具有非常重要的工程意义。ContentTemplateDataTemplate所有 ContentControl(如 Button)实现,会在控件模板 ControlTemplate 中的某些 ContentPresenter 将会负担解析和出现它们的使命,条件是你需要传递已往。ItemTemplateDataTemplate集合容器之以是可以或许出现内容就是由于它每一项都是一个 ContentPresenter,容器将会把界说的 ItemTemplate 信息交给每一个 ContentPresenter 的 ContentTemplate 中,把每一项的数据信息交给 ContentPresenter 的 Content 中,末了实现列表项的出现,具领会有 ItemsPresenter 的参与ItemsPanelItemsPanelTemplate属于 ItemsControl 和 ListBox 等数据呈出现容器,用于描述每一项应该如何排布,默认是 StackPanel Vertical 布局,你完全可以改成 WrapPanel,Canvas,StackPanel Horizontal,Grid 等等的布局容器CellTemplateDataTemplateWPF 出于 DataGrid 更好可视化的角度为你提供的办法
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |