Reputation: 67355
I know WPF has some powerful features, but it seems difficult for doing stuff like designing a simple dialog box.
I have a dialog layout with a label, textbox and buttons. But I don't want it in a grid format. I simply want the textbox snug up against the label. And the buttons below with some space between.
What are best practices for doing such a layout in WPF? The grid or any of the other layout features just don't seem designed to work well for something like this.
(And BTW, I used Visual Basic with DOS and then later with Windows. Back in those days, we had to design our interfaces using an intuitive drag and drop interface. These days, we've advanced to XAML which seems awkward in the designer and really requires typing all this stuff by hand if you want full control. What's up with that?)
Upvotes: 0
Views: 792
Reputation: 66501
Without a Grid, something like this may work:
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Some Label:" />
<TextBox />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="OK" />
<Button Content="Cancel" />
</StackPanel>
</StackPanel>
FWIW, I agree. WPF is much more difficult to build a fast layout in than WinForms. The visual editor is... less than ideal. I think the true power/flexibility of WPF shows when you get into advanced animations and such, which WinForms simply can't match.
Upvotes: 1