有什么办法如何告诉组件在WPF采取可用空间的100%?如何设置宽度为100%,在WPF
像
width: 100%;
在CSS
我有了这个XAML,我不知道如何强制电网采取100%的宽度。
<ListBox Name="lstConnections">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="LightPink">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Path=User}" Margin="4"></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Path=Password}" Margin="4"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Path=Host}" Margin="4"></TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
结果看起来像
alt text http://foto.darth.cz/pictures/wpf_width.jpg
我做到了粉红色所以很明显有多少空间没有考虑。我需要使粉红色的网格100%的宽度。
Link是死了... – 2017-03-10 14:02:18
@MartiniBianco我很抱歉,但这个问题是8岁。我甚至不记得照片中的内容,从那时起我也没有使用过WPF。 – 2017-03-11 13:01:50