My ramblings in Silverlight, Windows Azure, .NET, ASP.NET, C# (all the way from the UK)
A little place where i can store the snippets of information, which usually get lost in my tiny little brain, and will now forever remain enshrined in the google archives forever.

Friday, 14 March 2008

Stretches that don't work for ListBoxItems

I have a listbox where I want my items to stretch across the full listbox.

Unfortunately this doesn't seem to work in Silverlight 2.0 Beta 1, (works perfect in WPF).

After sometime searching I found the bug is in the control (within the generic.xaml file). The HorizontalAlignment is set to left for the ListBoxItem rather than using the template binding, anyways you can override this style using ListBoxItemContainer Style.

I have provided the code below which fixes the problem. I believe Microsoft will fix this bug in time, so you can remove it once fixed.