WPF Layout - Geting a column to fill available space?

Do you need the control behaviours of ListBox or are you using it for layout only If you are using it just for layout, you could swap the ListBox for a ItemsControl inside of a ScrollViewer This code (butchered to work in designer) show this: ScrollViewer.

Do you need the control behaviours of ListBox, or are you using it for layout only. If you are using it just for layout, you could swap the ListBox for a ItemsControl inside of a ScrollViewer. This code (butchered to work in designer) show this: -> The ListBox has some property of killing width on it's children, just like a TreeView does.So if you can avoid using it, for just layout reasons, this may be your fastest options.

Otherwise you'll need to databind the width of you Grid to the width of the dummy object outside the ListView, but the messy party is dealing with the width change as the scrollbar appears/disappears.

This is a great idea, but the ItemsControl does not have SelectionMode or a Selection changed event. – Vaccano Dec 4 '09 at 16:31 Thought you might want that. – Simeon Pilgrim Dec 4 '09 at 19:20.

The ListBox automatically displays the ScrollViewer when its contents don't fit in the available space. You can remove it from the XAML and it should still work okay.At least, it did for me. :) I tried your ControlTemplate out and it seemed to work really well.

The problem is that while the 3rd column resizes to the width of the ListBox, if the text in the 3rd column is very long, the 4th column won't appear until all of the text is visible. I also tried another layout method, which I'm not sure about performance-wise, but the idea was to use a DockPanel instead of a Grid. I added the third column last in the XAML to make it fill the remaining space, and docked it to the left (I docked the 4th column to the right).

It still would want to display the entire string in the 3rd column. I don't know why this is happening, and why the text won't wrap or use an ellipsis when the available space isn't enough for the text to display.

This still causes the same issue. I don't want the text to run off the screen. It needs to truncate.

– Vaccano Dec 4 '09 at 17:26.

Yes I would suggest the scroll viewer is messing you up, you could bind the Grid's width to the parent objects actual width, so there is a defined size in which the * has to actually fill.

I finally figure this out. The containing list box needed to set the horizontal scroll bar to disabled like this: One of these days I will figure out how all this "declarative stuff" works.

That fix is not related to "declarative". Xaml is declarative. Your problem was a flow problem, as your solution shows that you disabled horizontal flow behavior of the control.

– Simeon Pilgrim Dec 10 '09 at 3:18 Not quite sure what you mean by this. Are you saying my fix is the wrong way? I am using the declarative XAML properties to get the solution I need.

Either way, there is no other way to do this. – Vaccano Dec 10 '09 at 15:27.

The ListBox automatically displays the ScrollViewer when its contents don't fit in the available space. You can remove it from the XAML and it should still work okay. At least, it did for me.

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