Reputation: 76
Is there any way to get the XAML element by its tag value??
My code is like this :
<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>
I am binding Tag Property for Grid , is there any way to get an object of Grid by using Tag Propertty??
Sorry for less information the thing is grid is in ListBox .. How can i Access The Grid Object??
Thanks and Reagrds Yashavantha
Upvotes: 0
Views: 595
Reputation: 1402
Create a recursive method which uses System.Windows.Media.VisualTreeHelper to get all children of the page. For each child test if it's of type Grid and if it has a Tag equal to whatever you're looking for.
Upvotes: 2