Questions tagged «listboxitem»

6
如何获得一个ListBox ItemTemplate来水平拉伸ListBox的整个宽度?
我想让ListItems以其橙色背景扩展到Listbox的整个宽度。 目前,它们的大小仅与名字+姓氏一样。 我已经设置了所有可以设置的元素:Horizo​​ntalAlignment =“ Stretch”。 我希望ListboxItems的背景在用户拉伸Listbox时扩展,所以我不想输入绝对值。 我该怎么做才能使ListBoxItems的背景颜色填充ListBox的宽度? <Window x:Class="TestListBoxSelectedItemStyle.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TestListBoxSelectedItemStyle" Title="Window1" Height="300" Width="300"> <Window.Resources> <local:CustomerViewModel x:Key="TheDataProvider"/> <DataTemplate x:Key="CustomerItemTemplate"> <Border CornerRadius="5" Background="Orange" HorizontalAlignment="Stretch" Padding="5" Margin="3"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Width="Auto"> <TextBlock HorizontalAlignment="Stretch"> <TextBlock.Text> <MultiBinding StringFormat="{}{0} {1}"> <Binding Path="FirstName"/> <Binding Path="LastName"/> </MultiBinding> </TextBlock.Text> </TextBlock> </StackPanel> </Border> </DataTemplate> </Window.Resources> <Grid> <ListBox ItemsSource="{Binding …
356 xaml  listboxitem 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.