我被迫寻求帮助,而我自己却无法理解.我正在研究WPF-XAML桌面应用程序,其中GUI主要是动态生成的.
我的查询关于WrapPanel与ListBox项的样式.
请从我的usercontrol(.xaml)中找到一段代码:
<DockPanel x:Name="xResultPanel">
<ListView x:Name="bResultPanel" ItemsSource="{Binding ResultList, UpdateSourceTrigger=PropertyChanged}">
<ListView.ItemTemplate>
<DataTemplate>
<Expander Header="{Binding GroupName}" Style="{DynamicResource FeatureExpander2}">
<WrapPanel ItemWidth="140" Orientation="Horizontal">
<ListBox x:Name="ListOfTiles" ItemsSource="{Binding VideoSamples}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Width="120" Margin="10" HorizontalAlignment="Left">
<Image />
<TextBlock />
</StackPanel
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</Expander>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
上面的代码返回不是连续显示的ListBox项目,而是返回新行中的每个项目. 我试图为WrapPanel和ListBox设置MinWidth,Width等,但没有结果.
提前感谢所有相关技巧如何强制WrapPanel水平填充内容.