How do I make a WPF data template fill the entire width of the listbox? How do I make a WPF data template fill the entire width of the listbox? wpf wpf

How do I make a WPF data template fill the entire width of the listbox?


I also had to set:

HorizontalContentAlignment="Stretch"

on the containing ListBox.


<Grid.Width>    <Binding Path="ActualWidth"              RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollContentPresenter}}" /></Grid.Width>


Ok, here's what you have:

Column 0: WrapPanel
Column 1: Nothing
Column 2: ListBox

It sounds like you want WrapPanel on the left edge, ListBox on the right edge, and space to take up what's left in the middle.

Easiest way to do this is actually to use a DockPanel, not a Grid.

<DockPanel>    <WrapPanel DockPanel.Dock="Left"></WrapPanel>    <ListBox DockPanel.Dock="Right"></ListBox></DockPanel>

This should leave empty space between the WrapPanel and the ListBox.