views:

23

answers:

1

Hi,

Problem:
I have a set of items which have 3 elements:

  1. Image
  2. Description
  3. Numeric Value

I want to display these in a ListBox (similar to the way Excel displays emails in the summary view) however, i do not know the width of the description field. If i dont set a hard coded value for the width in the ItemTemplate im using for the ListBoxItem then the values dont line up. The idea is to have them displayed in the listbox like this:

image....Text1...................100
image....Text2 is longer..101
image....ShortText............102

Any help would be appreciated :)

+2  A: 

You want to use a Grid in the template for the list items, and ensure that the ItemsControl (or ListBox) has the Grid.IsSharedSizeScope="true" attached property and the column definitions have distinct SharedSizeGroup values. This will allow the all of the list box items to participate in determining the width of the columns even though technically they all have their own Grids. See further details here. Also see an earlier question: WPF grid across user controls?

JaredReisinger
Thanks :) I was using Grid.IsSharedSizeScope, but i was using it on the itemtemplate instead of the overall grid :) Thanks!
TerrorAustralis