如何计算网格中使用的标签 [英] How can I count the labels used in grid

查看:84
本文介绍了如何计算网格中使用的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在使用WPF开发表单。因为我在XAML中使用了几个标签。现在我想在xaml.cs文件中计算这些标签,即后端。

那我怎么能得到它。我还想在for循环中检索标签名称。请帮帮我

Hello,
I am developing a form using WPF. In that I've used several labels in XAML. Now I want to get count of these labels at xaml.cs file i.e at back-end.
So how can I get it. And I also want to retrieve name of label in for-loop. Please help me

推荐答案

MSDN写道:

Windows Presentation Foundation(WPF)发货许多常见的UI组件几乎在每个Windows应用程序中都使用,例如Button,Label,TextBox,Menu和ListBox。 从历史上看,这些对象被称为控件。 虽然WPF SDK继续使用术语控件来松散地表示在应用程序中表示可见对象的任何类 ,重要的是要注意,类不需要从Control类继承以具有可见的存在。从Control类继承的类包含ControlTemplate,它允许控件的使用者从根本上更改控件的外观,而无需创建新的子类。本主题讨论如何在WPF中常用控件(包括从Control类继承的控件和那些不从控件类继承的控件)。

Windows Presentation Foundation (WPF) ships with many of the common UI components that are used in almost every Windows application, such as Button, Label, TextBox, Menu, and ListBox. Historically, these objects have been referred to as controls. While the WPF SDK continues to use the term "control" to loosely mean any class that represents a visible object in an application, it is important to note that a class does not need to inherit from the Control class to have a visible presence. Classes that inherit from the Control class contain a ControlTemplate, which allows the consumer of a control to radically change the control's appearance without having to create a new subclass. This topic discusses how controls (both those that do inherit from the Control class and those that do not) are commonly used in WPF.



source:http://msdn.microsoft.com/en-us/library/bb613551%28v=vs.110%29 .aspx [ ^ ]



WPF使用 VisualTreeHelper [ ^ ],它公开了执行涉及可视树中节点的常见任务的方法。



请参考:

理解Vi WPF中的sual树和逻辑树 [ ^ ]

如何按名称或类型查找WPF控件? [ ^ ]

按类型查找WPF窗口中的所有控件 [ ^ ]


source: http://msdn.microsoft.com/en-us/library/bb613551%28v=vs.110%29.aspx[^]

WPF uses VisualTreeHelper[^] which exposes methods to perform common tasks involving nodes in a visual tree.

Please refer this:
Understanding the Visual Tree and Logical Tree in WPF[^]
How can I find WPF controls by name or type?[^]
Find all controls in WPF Window by type[^]


这篇关于如何计算网格中使用的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆