2012-09-13 133 views
0
Is there any way to get the XAML element by its tag value?? 

我的代码是这样的:有没有办法通过Tag属性获取XAML元素?

<Grid Tap="StackPanel_Tap" Tag="{Binding Type}" > 
     <Border BorderThickness="0" CornerRadius="0" BorderBrush="White" Width="100" Height="100" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="1" > 
     <Image Tag="{Binding Type}" Source="{Binding Location}" Opacity="1" Width="100" Height="100" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" UseLayoutRounding="True" > 
     </Image> 
     </Border> 
</Grid> 

我绑定标签属性的电网,是有没有办法通过使用标签Propertty得到电网的目标?

对不起,信息是网格在列表框中.. 我如何访问网格对象?

感谢和Reagrds Yashavantha

回答

2

创建一个使用System.Windows.Media.VisualTreeHelper获得页面的所有儿童的递归方法。对于每个孩子来说,如果它是网格类型的,并且它的标签等于你正在寻找的任何东西。

+0

谢谢..我会检查,并让你知道 – Yashavantha

+0

你告诉的答案工作正常,如果网格在外面...如果网格是在列表框? – Yashavantha

相关问题