WPF在DataTemplate中宽度设置
作者:互联网
以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>
标签:HorizontalContentAlignment,控件,为例,Stretch,ItemsControl,宽度,设置,WPF,DataTemplate 来源: https://www.cnblogs.com/wzwyc/p/15511817.html