Home > DeveloperSection > Forums > Set grid to 75% of parent grid using WPF
Andrew Deniel
Andrew Deniel

Total Post:29

Points:203
Posted on    October-14-2013 7:43 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 1959  View(s)
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!


lois waisbrooker
lois waisbrooker

Total Post:70

Points:494
Posted on    October-14-2013 7:55 AM

<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

Don't want to miss updates? Please click the below button!

Follow MindStick