I would like to find an example implementation as easy and elegant as possible using mvvm page management. Those. task - there is a list and you need to display buttons for its page-by-page view [<Back] [1] [2] [3] [4] [5] [Next>]
I think to do it through ItemsControl + ICollectionView, which would filter the displayed pages (5 current), but it’s not entirely clear how kosher a method is and the second point is how to display the highlighted current button in ItemControl without extra code wraps. Ie ItemTemplate and the code will be about the following. But what's not to like here is that the PageItem, when executing the command, should notify the PageCollection of changes in the current position, I would like IsSyncronizedCurrentItem to work, i.e. when you click on a button in the CollectionView, the state changes and CurrentItem switches to the current button automatically. Maybe there are some simpler solutions.
public class PageItem : BaseVM { ICommand SelectPageCommand {get;} } public class PageCollection : BaseVM { ICollectionView Pages {get;} void CreatePages() { pages = new List<PageItem>(); ... // create page items ... Pages = CollectionViewSource(pages) Pages.Filter+=(item)=> { // берем только 5 страниц от текущего элемента } } } <DataTemplate> <Button Command="{Binding SelectPageCommand} /> </DataTemplate>