Wpf: Alias for Grid鈥榮 RowDefinition and ColumnDefinition

Created on 5 Apr 2020  路  7Comments  路  Source: dotnet/wpf

I don't know if there is a way to make a alias for Grid鈥榮 cell. But I want to how to implement the following feature:

    <Grid x:Name="OuterGird">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" alias="id"/>
            <ColumnDefinition Width="*" alias="name"/>
            <ColumnDefinition Width="Auto" alias="birthday"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" alias="title"/>
            <RowDefinition Height="auto" alias="Address Bar"/>
            <RowDefinition Height="auto" alias="document "/>
            <RowDefinition Height="auto" alias="status bar "/>
        </Grid.RowDefinitions>

        <Grid x:Name="InnerGrid" Grid.Column="id" Grid.Row="title"/>
        <TextBlock x:Name="Address" Grid.Column="id" Grid.Row="Address Bar"/>
        ...
    </Grid>

so when I Change the OuterGrid' columns defintion or rows difinition I don鈥檛 need to change the InnerGrid's properties of Grid.Column or Grid.Row
Thank you for your attention

issue-type-enhancement

Most helpful comment

@weltkante Do you mean that: we can use the Name property to set to the Column? Just like the code

       <Grid.RowDefinitions>
        <RowDefinition Height="auto" Name="Title"/>
        <RowDefinition Height="auto" Name="AddressBar"/>
      </Grid.RowDefinitions>

    <Grid x:Name="InnerGrid"  Grid.Row="Title"/>
    <TextBlock x:Name="Address"  Grid.Row="AddressBar"/>

I very much agree with this view

All 7 comments

Looks like a dup of #166 ?

Looks like a dup of #166 ?

NO the #166 just want to use a quick method to define columns and rows but when the column or rows definition changed such as

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" alias="id"/>
            <ColumnDefinition Width="*" alias="name"/>
            <ColumnDefinition Width="Auto" alias="birthday"/>
        </Grid.ColumnDefinitions>
<Grid x:Name="InnerGrid" Grid.Column="1" Grid.Row="title"/>

to

<Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" alias="id"/>
            <ColumnDefinition Width="Auto" alias="AddAnewcolumn"/>
            <ColumnDefinition Width="*" alias="name"/>
            <ColumnDefinition Width="Auto" alias="birthday"/>
        </Grid.ColumnDefinitions>
<Grid x:Name="InnerGrid" Grid.Column="2" Grid.Row="title"/>

the column of "InnerGrid" from Grid.Column="1" to Grid.Column="2" most of the elements should changed the properties. but using the aliases these modifies are unnecessary.
thank you for your attention

You can already give a name to columns/rows like you can give to any other element, so why invent a new attribute alias?

You can already give a name to columns/rows like you can give to any other element, so why invent a new attribute alias?

I believe you replied without reading my question. I want to know the alias could be added to the grid so the other elements can used it such as the an Attached Property like Grid.Column. then when we insert a new row or new column we needn't modify the property but use Grid.Column or Grid.Row will need to changed the property

I believe you replied without understanding my response. I said there's already a way to name rows/columns, via 'Name' property, so why does it need to have two names?

In other words, why should I have to type <GridColumn Width="auto" Name="age" Alias="age" /> if I need to make use of both functionalities?

@weltkante Do you mean that: we can use the Name property to set to the Column? Just like the code

       <Grid.RowDefinitions>
        <RowDefinition Height="auto" Name="Title"/>
        <RowDefinition Height="auto" Name="AddressBar"/>
      </Grid.RowDefinitions>

    <Grid x:Name="InnerGrid"  Grid.Row="Title"/>
    <TextBlock x:Name="Address"  Grid.Row="AddressBar"/>

I very much agree with this view

@weltkante Do you mean that: we can use the Name property to set to the Column? Just like the code

       <Grid.RowDefinitions>
        <RowDefinition Height="auto" Name="Title"/>
        <RowDefinition Height="auto" Name="AddressBar"/>
      </Grid.RowDefinitions>

    <Grid x:Name="InnerGrid"  Grid.Row="Title"/>
    <TextBlock x:Name="Address"  Grid.Row="AddressBar"/>

I very much agree with this view

hahahaha , I don't know how to express my idea. but thank lindexi . yes that my mean
sorry for my poor english
thank you all

Was this page helpful?
0 / 5 - 0 ratings