views:

42

answers:

2

I have been working on an app with a datagrid from the wpf toolkit and the width was not specified in the xaml (default to auto), and it was working fine. It would extend the window width as I resized the window. However, all the sudden the "auto" width is massive and I don't know why. When I pull the xaml file up in blend it shows auto width is 50002 pixels. I barely touched anything else in my xaml since it happened. Anyone know why it is doing this and where that number came from? Thanks

A: 

If you were doing any manual resizing using the Visual Studio IDE then perhaps this could have happened or you could have accidently typed in the wrong size of 50002. Removing the widths and setting to auto should fix the issue.

Trey Sargent
I never use the design screen. I have tried specifically setting width to auto, but it's the same thing. My code was fine before with no width property set. It's a really strange problem.
AdamD
+3  A: 

The most common cause for this that I've seen is when the control is inside a StackPanel with Orientation=Horizontal. StackPanels don't constrain their controls in the stacking direction so if nothing else constrains the control it grows to some maximum size.

If this is the issue try replacing your StackPanel with an equivalent DockPanel or Grid.

Bryan Anderson
Even if it's not a `StackPanel`, I'd suspect this has more to do with what the `DataGrid` is contained within, than the control itself.
Will Eddins
This was exactly the problem...except it seemed to appear randomly at some point which was what puzzled me. Anyway, a grid with columns is working perfectly now. Thanks.
AdamD