Reputation: 5478
I've designed a WPF window in Visual Studio 2010 with several controls in it. The window is set as default for the program startup. The size of this window is sufficient for all controls to fit properly.
When I execute the program, for some reason the window starts much smaller than the size shown in designer, and controls do not fit. How to troubleshoot this problem?
The window opening code is as follows:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
Title="Main" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="548" d:DesignWidth="924" SizeToContent="WidthAndHeight" xmlns:my="clr-namespace:ElanceTracker" WindowStartupLocation="CenterScreen" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon" xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar" xmlns:dxca="http://schemas.devexpress.com/winfx/2008/xaml/carousel" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts">
Upvotes: 0
Views: 1265
Reputation: 1
This bug still exist in the newest Visual Studio. I always design my windows 16 pixels wider and 16 pixels higher to get the right size at run time.
Upvotes: 0
Reputation: 941455
You are using the wrong attributes. DesignWidth and DesignHeight only set the design time size. You want Width and Height.
Upvotes: 2
Reputation: 3731
Try changing DesignHeight and DesignWidth for Height and Width respectively, and also, set SizeToContent to None.
Upvotes: 4