combobox - Make WPF ComboBoxes fill a whole column width -


I'm having trouble creating a in ComboBox to fill the whole column width in a GridViewColumn . When the column is resized it should be resized.

In the following example, I have a stackpanel inside a ComboBox . It is set to stretch and actually StackPanel width Will fret to fill.

Then I connect a ListView with a column, which contains StackPanel with ComboBox . Both the stackpayel and combo boxes are set to stretch for both, but they do not do this. I use background colors to identify the size of StackPanel s, and by the time I add the elements in the ComboBox unless I set the width There is no red that it needs more width

I also tried to play with property without success horizontalcontentAlignment

  & Lt; StackPanel height = "59" margin = "45,12,38,0" vertical alignment = "top" background = "green" & gt; & Lt; Combo box horizontal alignment = "stretch" /> & Lt; / StackPanel & gt; & Lt; ListView x: name = "MyListView" margin = "0,106,0,0" & gt; & Lt; ListView.View & gt; & Lt; GridView & gt; & Lt; GridViewColumn header = "number" width = "70" & gt; & Lt; GridViewColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; StackPanel Background = "Red" Orientation = "Horizontal" Horizontal Alignment = "Statch" & gt; & Lt; Combo box horizontal alignment = "stretch" /> & Lt; / StackPanel & gt; & Lt; / DataTemplate & gt; & Lt; /GridViewColumn.CellTemplate> & Lt; / GridViewColumn & gt; & Lt; / GridView & gt; & Lt; /ListView.View> & Lt; ListViewItem & gt; & Lt; / ListViewItem & gt; & Lt; / ListView & gt; Try setting    

style to ListViewItem . I also removed your stackpanel.

  & lt; ListView x: name = "MyListView" margin = "0,106,0,0" & gt; & Lt; ListView.Resources & gt; & Lt; Style TargetType = "ListViewItem" & gt; & Lt; Setter Property = "Horizontal Content Alignment" Value = "Statch" /> & Lt; / Style & gt; & Lt; /ListView.Resources> & Lt; ListView.View & gt; & Lt; GridView & gt; & Lt; GridViewColumn header = "number" width = "170" & gt; & Lt; GridViewColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Combo box / & gt; & Lt; / DataTemplate & gt; & Lt; /GridViewColumn.CellTemplate> & Lt; / GridViewColumn & gt; & Lt; / GridView & gt; & Lt; /ListView.View> & Lt; ListViewItem & gt; & Lt; / ListViewItem & gt; & Lt; / ListView & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -