>>Hi people
>>
>>On Kevin Goff's recommendation I got the book "Microsoft Visual C# 2008 Step by Step"
>>
>>In the very first stage they describe creating a simple WPF form with a label, textbox and button.
>>I followed it exactly, and the button is the same height as the textbox in the IDE.
>>
>>However after compiling and running it, the button shows up slightly larger and taller than the textbox and the form looks like crap because the button looks mis-sized.
>>
>>How can I make sure that the development and runtime is properly WISIWYG and if this were to happen to a form with many buttons and textboxes, it would look a mess.
>>
>>An image of what I am talking about can be viewed here:
>>
>>
http://www.foxite.com/uploads/5fdee885-ecb1-42dc-b555-c6a5a6eb99e6.jpg>>
>>Notice that in design time the button and textbox appear to have the same height, but in the runtime the button has grown downwards and looks terrible.
>>
>>I am sure it has something to do with the Margin since the button resizes with the form but cannot see what.
>>
>>Thanks.
>
>Don't have the book so don't know what steps you followed. Can you post the XAML for the window?
>Best,
>Viv
Hi Viv
This is what I did (C#):
1. in VS, New Project - select WPF Project
2. Resize the default form as in the image below (after point 4)
3. From toolbar select a textbox and click on form. Resize textbox width
4. Select button from toolbar and click on form. Reposition the button so the VS indicators show they are aligned. See image below:
http://www.foxite.com/uploads/ec51f8fa-33d3-4b05-8656-c8194a6acc57.jpg5. Run the form. Result is below.
http://www.foxite.com/uploads/e512a3e9-c326-45b4-bb82-6ff9619eacfc.jpgNote that I made no other changes to the objects and the VS IDE showed that the textbox and button were the same size. Yet when I run the form I get a larger button.
This is the XML produced by VS in the above steps:
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="117" Width="386">
<Grid>
<TextBox Height="23" Margin="24,27,134,0" Name="textBox1" VerticalAlignment="Top" />
<Button HorizontalAlignment="Right" Margin="0,27,53,29" Name="button1" Width="75">Button</Button>
</Grid>
</Window>
Is this a bug in the IDE for WPF of what is causing this non WSYWIG effect. Since I am a complete newbie at WPF, this is most frustrating.
Another thing is that although I have not set any "anchor" property, the button assumes its own setting and acts like it is anchored by expanding when the form is resized. The textbox does not. I am sure there is some step missing from this but this is what the book says exactly step by step.
Please ease my frustration :)
Bernard