Silverlight 3: ListBox DataTemplate HorizontalAlignment

后端 未结 6 440
误落风尘
误落风尘 2020-12-05 10:24

I have a ListBox with it\'s ItemTemplate bound to a DataTemplate. My problem is I cannot get the elements in the template to stretch to the full width of the ListBox.

<
6条回答
  •  广开言路
    2020-12-05 11:04

    I spent an hour trying to resolve this one. Very very frustrasting. You don't have to override the entire default style for the ListBoxItem. I couldn't get this to work. In the end I resolved the issue by simply overriding just the HorizontalContentAlignment property in my ListBox.ItemContainerStyle section e.g:

                
                    
                        
                    
                        
    
                        
                            
                                
                                    
                                        
                                    
                                    
                                
    
                            
                        
                    
    

    This worked a treat for me.

    Myles

提交回复
热议问题