Do you know any controls inherited from the ItemsControl that have horizontal orientation of items?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
While the promoted answer is great, here's an alternative if you want the items to stretch.
The top answer is good, but I couldn't get it to work with UserControls. If you need UserControls, this should help.
ItemsControl with Horizontal Usercontrols
My Version:
To bind to data, you will need to add an
ItemsSource
to theItemsControl
in the XAML or code behind. Also note thatuc:
would be thexmlns:uc="NamespaceOfMyControl"
declared at the top of the file.This is an example of how to do horizontal scrolling within an ItemsControl.
Firstly the main window viewmodel class used to get/set the list of items we wish to display.
MainWindowViewModel.cs
The main window xaml for the view:
MainWindow.xaml
Depending on how high/wide your client area is, this will result in this kind of layout, overflow items scrolled horizontally:
More details can be found at this blog link, including an example on how to do the scrolling vertically:
http://www.technical-recipes.com/2017/how-to-orient-wrappanel-items-within-itemscontrol-lists-vertically-and-horizontally/
Simply change the panel used to host the items: