I currently in the process of building a Download Manager that uses WPF, as I am sick of large downloads timing out and not being resumable, and I have never been happy with any of the download managers out there. I want something SIMPLE, basic, you copy a Url in and it downloads it… reliably… perhaps sometimes at a limited download rate if I don’t want my bandwidth chewed all at once. I’ll probably post the result on CodePlex where it can be promptly lost in the sea of projects.
Anyway I was display a ListView of the files and I wanted a progress bar in one of the cells, but I couldn’t get it to stretch to the size of the cell, I always had to set the size of the progress bar… Which seems silly, because I would have thought that Stretch would be the default behaviour for a cell (I guess it was deemed the most common content would be text which you don’t want stretched you want left aligned). Anyway long and short of it is, it’s easily fixed thanks to an article by Ian Griffiths.
Example (repeated here for quick reference)
Add this Xaml to your ListView…
<ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> </Style> </ListView.ItemContainerStyle>