Friday, August 3, 2012

Make GridColumns align in two different Grids in WPF XAML

In XAML UI, some times we want to make GridColumn Width synchronized with other GridColumns in other Grids.

WPF provided a property called  SharedSizeGroup  which allows sizing properties shared between ColumnDefinition or RowDefinition.

And remeber to set  Grid.IsSharedSizeScope="True".


However , when we want one column take up all the available space, like the example above. You will find out that even you write Width="*" still doesn't work as SharedSizeGroup will make it as short as possible.

My solution is , Shared all the columns size except the one contain TextBox.


            <Grid  Grid.IsSharedSizeScope="True">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Grid Name="Grid1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" SharedSizeGroup="a" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="auto" SharedSizeGroup="c"/>
                        <ColumnDefinition Width="auto"  SharedSizeGroup="d"/>
                    </Grid.ColumnDefinitions>
                 ....
                </Grid>
                <Grid Name="Grid2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" SharedSizeGroup="a" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="auto" SharedSizeGroup="c"/>
                        <ColumnDefinition Width="auto"  SharedSizeGroup="d"/>
                    </Grid.ColumnDefinitions>
                 .........
                </Grid>

13 comments:

  1. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me.
    Data Science Training in Indira nagar
    Data Science Training in btm layout
    Data Science Training in Kalyan nagar
    Data Science training in Indira nagar
    Data science training in bangalore

    ReplyDelete
  2. Attend The Data Scientist Courses From ExcelR. Practical Data Scientist Courses Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Scientist Courses. Data Scientist Courses

    ReplyDelete
  3. In the wake of perusing your article, I was astounded. I realize that you clarify it well overall. What's more, I trust that different perusers will likewise encounter how I feel in the wake of perusing your article.
    data science institutes in hyderabad

    ReplyDelete
  4. Excellent and informative blog. If you want to become data scientist, then check out the following link. Data Science Certification in Hyderabad

    ReplyDelete
  5. iDealshare VideoGo Crack is a multi-purpose, multimedia file format converter. With this app, you can convert video and audio easily. IDealShare Videogo Keygen

    ReplyDelete
  6. Kaspersky Crack is a PC, mobile, and tablet protection software. When you browse through the internet, websites and advertisements can track your activity. Kaspersky Total Security Activation Code

    ReplyDelete
  7. I am a lucky sister, I cried unto God for a sister, but he gave me two, not only two, but good and cute two. Happy Birthday twin sisters.
    Birthday Twins

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete