以ItemsControl为例,主要是在ItemContainerStyle中设置一下HorizontalContentAlignment为Stretch,就可以使控件填充满列表。
<ItemsControl x:Name="TaskList" ItemsSource="{Binding CurrentInfo.Options}" Margin="12"> <ItemsControl.ItemContainerStyle> <Style> <Setter Property="Control.FontSize" Value="48"/> <Setter Property="Control.HorizontalContentAlignment" Value="Stretch"/> <Setter Property="Control.Margin" Value="6"/> </Style> </ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate> <Button Content="{Binding}" Click="Button_Click"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>