Is there any way to get the XAML element by its tag value??
我的代码是这样的:
<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>
我正在为 Grid 绑定 Tag 属性,有什么方法可以使用 Tag 属性获取 Grid 对象吗?
抱歉,信息较少,网格位于列表框中。
我如何访问网格对象?
感谢致敬
亚沙万塔
创建一个递归方法,使用 System.Windows.Media.VisualTreeHelper 获取页面的所有子级。对于每个子项,测试它是否属于网格类型,以及它是否具有与您要查找的内容相同的标签。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)