大佬教程收集整理的这篇文章主要介绍了xaml – ListBoxItem HorizontalContentAlignment在ListBox的整个宽度上拉伸,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的列表框
<ListBox Itemssource="{Binding Events}" behaviors:ItemClickCommandBehavior.Command="{Binding EventSELEctedCommanD}" ItemTemplate="{Staticresource EventListTemplateSELEctor}"/>
它的DataTemplates是一个单独的xaml资源文件:
<DataTemplate x:Key="EventListHeaderTemplate"> <Border HorizontalAlignment="Stretch"> <Grid Height="50"> <Grid.columnDeFinitions> <columnDeFinition Width="*"/> <columnDeFinition Width="6*"/> </Grid.columnDeFinitions> <Image Grid.column="0" source="{Binding ImageUri}" VerticalAlignment="Center" HorizontalAlignment="Center" Height="30"/> <TextBlock Grid.column="1" Text="{Binding SomeText}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="Black"/> </Grid> </Border> </DataTemplate>
我不能得到真正弹力的物品,我不知道问题在哪里.我试图设置ItemContainerStyle HorizontalCOntentAlignment =“Stretch”,它没有工作.我尝试了许多其他组合,似乎只有将边框或网格宽度设置为常量工作,而另一种解决方案的作用是将边框宽度设置为绑定到包含ListBox的ActualWidth,但是我想使用Stretch变种如果可以使它工作.
使用竞争样式(这适用于任何xaml变体实际上)的方式是明确定义ListBoxItem的样式来处理空间使用.
这给了xaml一个提示,它以这种方式填充(拉伸)到屏幕区域:
<ListBox Name="lbTest" HorizontalContentAlignment="Stretch" > <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate>...</ListBox.ItemTemplate>
以上是大佬教程为你收集整理的xaml – ListBoxItem HorizontalContentAlignment在ListBox的整个宽度上拉伸全部内容,希望文章能够帮你解决xaml – ListBoxItem HorizontalContentAlignment在ListBox的整个宽度上拉伸所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。