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
2010-01-02 01:58:58
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
2010-01-02 02:19:26
+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
2010-01-02 23:50:18
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
2010-01-02 23:52:44
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
2010-01-03 04:41:58