我有一个像这样的XAML代码:
<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"/>
我想得到x:Uid和Grid.Row&amp; C#部分中每个图像标记的Grid.Column属性。
我该怎么做?
还有吗?
答案 0 :(得分:1)
不确定。为行和列调用静态Grid
方法,并从图像对象本身获取Uid
属性。
int row = Grid.GetRow(bimage0);
int col = Grid.GetColumn(bimage0);
string uid = bimage0.Uid;