以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>

 

相关文章:

  • 2022-01-10
  • 2021-04-16
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
相关资源
相似解决方案