How to make DockPanel fill available space?

Bind the Width of the DockPanel to the ActualWidth of the ListBoxItem : DockPanel Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}} EDIT: another option : you could just redefine the ItemContainerStyle so that the ListBoxItem is stretched horizontally : ListBox. ItemContainerStyle.

Bind the Width of the DockPanel to the ActualWidth of the ListBoxItem : ... EDIT: another option : you could just redefine the ItemContainerStyle so that the ListBoxItem is stretched horizontally.

I tried using that binding and it seems to be causing the ListBoxItem to continually grow in size, when viewing with Snoop, I saw the width of both the ListBoxItem and the DockPanel exceed 300,000. – Richard C. McGuire Jul 3 '09 at 19:23 Try binding to the ActualWidth of the ListBox itself, then... – Thomas Levesque Jul 3 '09 at 20:25 2 Oh, ok, I get it... you must set LastChildFill="False" on the DockPanel, otherwise the second TextBlock is stretched – Thomas Levesque Jul 3 '09 at 20:47 I ended up locating your second approach and going that route.

– Richard C. McGuire Jul 3 '09 at 21:13.

DockPanels are evil. Temptation to use StackPanel/DockPanel combination for complex layouts leads to "layout dead ends". Use a Grid: I use Grids almost exclusively, using a seperate grid for each block of elements that "belong together.

I don't think DockPanels are evil, they can be pretty useful sometimes... however I must agree that it was probably not the best option in that case – Thomas Levesque Jul 3 '09 at 21:18 Of course this is subjective and they are not an absolute evil ;) But look where Rich already going - using ItemContainerStyle (semi-advanced stuff) for simple task - kinda indicative... – Sergey Aldoukhov Jul 3 '09 at 21:46 I had considered a Grid at the outset. However, given a narrow ListBox, or long enough value for the Name or Price properties the two TextBlocks will end up overlapping their values. In addition I would hardly classify laying out two TextBlocks at opposite ends of a panel as a "complex layout".

– Richard C. McGuire Jul 8 '09 at 2:31 Sorry for commenting to this old post, but using a grid is also a simple and equally effective solution to the problem. The overlap problem is avoidable.

+1 – code4life Jul 22 at 12:51.

DockPanel is made Visible.As far as I can tell, the problem seems to happen only when the DockPanel contains a user control (XtraUserControl or just a UserControl). Make DockPanel.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions