Reputation: 87
i have a XAML code like this:
<Grid RenderTransformOrigin="0.501,0.481">
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/bg.png"/>
</Grid.Background>
<Grid HorizontalAlignment="Left" Height="670" Margin="50,40,0,0" Width="670" Background="#FFFFDF1A">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image x:Name="bimage0" x:Uid="1" HorizontalAlignment="Left" Height="83.75" Width="83.75" Source="Assets/Chessman/bPawn.png" Stretch="Fill" Grid.Column="7" Grid.Row="6"/>
<Image x:Name="bimage1" x:Uid="1" HorizontalAlignment="Left" Height="83.75" Width="83.75" Source="Assets/Chessman/bPawn.png" Stretch="Fill" Grid.Column="6" Grid.Row="6"/>
I want to get x:Uid and Grid.Row & Grid.Column Attribute for each Image Tag in C# part.
how can i do that?
is there anyway?
Upvotes: 0
Views: 486
Reputation: 1118
Sure. Call the static Grid
methods for row and column, and grab the Uid
property from the image object itself.
int row = Grid.GetRow(bimage0);
int col = Grid.GetColumn(bimage0);
string uid = bimage0.Uid;
Upvotes: 1