[英]How to create tile interface in wpf project
Can anyone tell me how do i achieve grid view interface in wpf project. 谁能告诉我如何在WPF项目中实现网格视图界面。 I am trying to create a sqaure tile interface which i want to bind with a List data structure such that it will populate and create the same number of tiles as that of List's count. 我正在尝试创建一个sqaure tile接口,该接口要与List数据结构绑定,以便它将填充并创建与List计数相同数量的tile。 The image given below might help you in understanding the type of interface. 下面给出的图像可能有助于您了解接口的类型。 I know this might be a silly question but i am stuck. 我知道这可能是一个愚蠢的问题,但我被困住了。 Thanx for your help in advance. 感谢您的帮助。
As often in such situations, use the ItemsControl
class . 通常在这种情况下,使用ItemsControl
类 。 For the ItemsPanel
, you can use a WrapPanel
, which will create the effect of "filling up lines" and wrapping once the horizontal space is used up. 对于ItemsPanel
,您可以使用WrapPanel
,一旦水平空间用完,它将创建“填充线”并包装的效果。
Then, in order to create a grid-like appearance (ie not only rows, but also visible columns), make sure that each item is displayed with the same size - that is something that you should be able to ensure in the ItemTemplate
of your ItemsControl
, for example by using one of the following to ways: 然后,为了创建网格状外观(即,不仅行,而且可见列),请确保每个项目都以相同的大小显示-这是您应该能够在自己的ItemTemplate
中确保的ItemsControl
,例如,通过以下方式之一:
Width
and Height
properties of your item views (that is, the root elements of your item templates). 您可以为项目视图的Width
和Height
属性(即项目模板的根元素)手动分配固定值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.