SET GRID TO 75% OF PARENT GRID USING WPF

Andrew Deniel

Total Post:29

Points:203
Posted by  Andrew Deniel
WPF 
WPF
 2472  View(s)
Ratings:
Rate this:
<ScrollViewer Grid.Row="2">
    <Grid>
        <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
        <Grid Grid.Row="0" HorizontalAlignment="Left" Margin="10,5,0,0" Width="500">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.Background >
                    <ImageBrush ImageSource="Public\Images\chat_green-textarea.png"/>
                </Grid.Background>
                <TextBlock Padding="5" Foreground="White" FontSize="15" TextWrapping="Wrap">Lorem Ipsum is simply dummy text of the printing and typesetting industry.
 </TextBlock>                                    
            </Grid>
            <Grid Grid.Row ="1">
                <Image Source="Public\Images\chat_green-textarea-tail.png" Height="20" Width="30" HorizontalAlignment="Left" Margin="10,-4,0,0"/>
            </Grid>
        </Grid>
    </Grid>
</ScrollViewer>
I am displaying a Text in
a Grid, but I want its max width
to be set equals to the 75% of its parent grid. Thanks!
  1. lois waisbrooker

    Post:70

    Points:494
    Re: Set grid to 75% of parent grid using WPF

    <ScrollViewer>
        <Grid>
            <Grid.ColumnDefinitions>
                <columndefinition Width="3*"/>
                <columndefintiion Width="1*"/>
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0">
               --------------
            </Grid>
        </Grid>
    </ScrollViewer>

    Put your target grid in the first column of the wrapper grid and now it will have 75% width of it's parent.

      Modified On Oct-16-2013 10:10:44 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!