有没有一种简单的方法来循环WPF窗口中的控件? [英] Is there an easy way to cycle through controls in a WPF Window?
本文介绍了有没有一种简单的方法来循环WPF窗口中的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的XAML窗口,其中包含30多个TextBlock控件,每个控件都有自己在运行时定义的标签。
有没有简单的方法循环浏览表格上的控件进行比较程序?
我原计划走的路线...
< pre lang =vb> 对于 每个 Control in 我。控制
' if控制是具有特定标记的文本块然后...
下一步
解决方案
请参阅: https:// msdn.microsoft.com/en-us/library/ms753391%28v=vs.110%29.aspx [ ^ ]。
此CodeProject文章也很有用:了解WPF中的可视树和逻辑树 [ ^ ]。
-SA
I have a simple XAML window with a grid that contains 30+ TextBlock controls, each with it's own tag defined at run time.
Is there an easy way to cycle through the controls on my form to do a comparison routine?
I had planned on going the route of...
For Each Control in Me.Controls
'if control is text block with a certain tag then...
Next
解决方案
Please see: https://msdn.microsoft.com/en-us/library/ms753391%28v=vs.110%29.aspx[^].
This CodeProject article can also be useful: Understanding the Visual Tree and Logical Tree in WPF[^].
—SA
这篇关于有没有一种简单的方法来循环WPF窗口中的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文