0
A
回答
1
定義WrapPanel
爲ListBox
的ItemsPanel
:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ></WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
不要忘記設置Width
或MaxWidth
到畫布面板。一旦達到最大寬度,它將開始將內容放置在新線上...
+0
這似乎工作,但我沒有得到任何滾動條? –
0
使用寬度設置爲值的WrapPanel。對於例如運行下面的代碼:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="350" Width="525" >
<Window.DataContext>
<local:ParentViewModel />
</Window.DataContext>
<ListBox Height="auto" ItemsSource="{Binding MyList,Mode=TwoWay}">
<ListBox.Style>
<Style TargetType="{x:Type ListBox}">
<Setter Property="ItemTemplate" >
<Setter.Value>
<DataTemplate>
<Button Content="{Binding}" Padding="15,5" Margin="100,40,0,0"
Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}},Path=DataContext.RemoveButtonCommand}"
CommandParameter="{Binding}"
/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Style>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=ActualWidth}"
>
</WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
您將獲得垂直和水平滾動條。都根據窗口的高度和寬度用listbox中的元素進行調整。 (請綁定你自己的列表框源代碼)
相關問題
- 1. 在DataGridView圖像列中顯示多個圖像?可能嗎?
- 2. 圖像不能顯示在列表中
- 3. 在列表視圖中顯示圖像
- 4. 在列表視圖中顯示圖像
- 5. Android:顯示具有多個列和行的圖像(nxn)。有內存問題
- 6. WPF列表框不會顯示包裝在多列中的圖像
- 7. 無法在Silverlight中的列表框控件中顯示圖像
- 8. 未在用戶控件的列表框中顯示圖像
- 9. Windows Phone在綁定的列表框中顯示RSS圖像
- 10. 是否有可能在食譜中顯示圖像直方圖
- 11. 在表格的某些列中顯示具有空值的行
- 12. fpdf使用多列單元格的表格行顯示圖像
- 13. 綁定後圖像不顯示在列表框中
- 14. 僅在列表框中顯示圖像文件擴展
- 15. C#如何在列表框中循環顯示圖像
- 16. 在新聞稿中的多個表格行上顯示圖像
- 17. 具有透明圖像的CSS邊框圖像在Android上顯示邊緣
- 18. 顯示圖像列表
- 19. 無法顯示列表中的圖像
- 20. 在數據表列顯示的圖像
- 21. 顯示在列表旁邊的圖像
- 22. 在行中顯示圖像
- 23. 具有多個複選框和圖像的列表視圖視圖?
- 24. 在列表框中顯示消息框中的多個信息
- 25. 我試圖顯示在列表視圖圖像的列表,但
- 26. 如何在列表框中顯示所有單詞時顯示在單行中
- 27. 顯示工具提示中的圖像
- 28. VB.NET如何僅在可見的圖片框中顯示圖像
- 29. 在列表框中突出顯示多個項目/行
- 30. 顯示列表框中的圖像保持文件鎖定
ListView可以幫助你 –
@不幸我現在來看看這個,謝謝你回到我身邊。 –