【发布时间】:2021-09-25 20:29:47
【问题描述】:
我想要一个蓝线拉伸结束列表项,但只有几个来。
我给了
HorizontalAlignment = "拉伸"
但它不起作用。
完整列表代码在这里
<Grid>
<ListBox Name="MyListBoxAddData" Margin="20" BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Label Content="{Binding Id}"/>
<Label Content="{Binding Path=Questions,Mode=TwoWay}"/>
<RadioButton Content="{Binding Path=Option1,Mode=TwoWay}" Margin="10 5"/>
<RadioButton Content="{Binding Path=Option2,Mode=TwoWay}" Margin="10 5"/>
<RadioButton Content="{Binding Path=Option3,Mode=TwoWay}" Margin="10 5"/>
<RadioButton Content="{Binding Path=Option4,Mode=TwoWay}" Margin="10 5"/>
<TextBlock Text="{Binding Answer}" />
<Separator HorizontalContentAlignment="Stretch"/>
<Rectangle HorizontalAlignment="Stretch" Fill="Blue" Height="4" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
我想要一个完整的行。 提前谢谢你
【问题讨论】:
-
问题可能是 StackPanel。您可以尝试用网格围绕您的堆栈面板并将矩形移出堆栈面板。
-
查看编辑后的答案,了解您将如何实际解决此问题。
标签: c# wpf xaml data-binding listboxitem