我不知道如何在WPF
中执行此操作。这是我的代码:
<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. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</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>
我在Text
中显示Grid
,但我希望将其最大宽度设置为等于其父网格的75%。谢谢!
答案 0 :(得分:1)
放入另一个带有两列列定义的网格
<ScrollViewer>
<Grid>
<Grid.ColumnDefinitions>
<columndefinition Width="3*"/>
<columndefintiion Width="1*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
... <snip> ...
</Grid>
</Grid>
</ScrollViewer>
将目标网格放在包装网格的第一列,现在将它放入 它将拥有75%的父母宽度。