XAML-C#中的图像网格属性

本文关键字:网格 属性 图像 XAML-C# | 更新日期: 2023-09-27 18:23:45

我有一个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&C#部分中每个图像标记的Grid.Column属性。

我该怎么做?

有吗?

XAML-C#中的图像网格属性

当然。调用行和列的静态Grid方法,并从图像对象本身获取Uid属性。

int row = Grid.GetRow(bimage0);
int col = Grid.GetColumn(bimage0);
string uid = bimage0.Uid;