2013-05-02 68 views
1

有没有什么办法可以在windows phone中获得c#中所有xaml标签(或任何其他标签)的列表而无需给它们命名?是否可以在c#中列出所有的xaml图片标签?

喜欢的东西:

var list = this.GetElementsByTagName("Image"); 
+1

这可能会帮助:http://stackoverflow.com/questions/7153248/wpf-getting-a-collection-of-all-controls-for-a-给定类型的页面 – Zadam 2013-05-02 14:18:34

+0

这可能也有帮助:http://stackoverflow.com/questions/974598/find-all-controls-in-wpf-window-by-type – Dilshod 2013-05-02 14:20:28

+0

@Dilshod这真的很简单,谢谢 :) – Louy 2013-05-02 14:55:47

回答

1

你可以做这样的事情。

foreach(UIElement item in YourContainer.Children){ 
    MessageBox.Show(item.GetType().ToString()); 
} 

它会返回类似System.Window.Control.Image

相关问题