Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, WPF provides a rather elegant way to implement this because its templating mechanism allows you to fill the unused area in a
GridViewwith whatever you like.All you need to do is modify the
ListViewtemplate to paint the unused section of the with aVisualBrushthat typically consists of twoGridViewItemsstacked vertically (in the general case it will beAlternationCountGridViewItems).The only complexity is choosing which color to start with when painting the unused section of the
ScrollViewer. This is calculated asItems.CountmoduloAlternationCount. The solution is to create a simpleControlthat does this calculation and use it in ourListViewtemplate. For the sake of my explanation I will call the control “ContinueAlternation”.The
ListViewtemplate which would be mostly the default template with alocal:ContinueAlternationcontrol added below theScrollViewerusing aDockPanel, like this:The
ContinueAlternationcontrol will be displayed as aRectanglepainted with a tiledVisualBrushcontaining anItemsControlthat shows dummy rows, as follows:The
DataContexthere will be an array of dummyListViewItemgenerated in code-behind from the givenAlternationCountandItemsCount:Note that this same code could be written with
PropertyChangedCallbackinstead ofOnPropertyChanged.You also need to do something to make sure the blank rows are the desired height. The easiest way to do this is to set either
MinHeightorContentin yourItemsContainerStyle. AlternativelyContinueAlternationcould set the height when it constructs eachListViewItem.I typed all this code off the top of my head, but it is similar to code I’ve written and used before so it ought to work basically as-is.