Emulating Dock and Anchor in a WPF window

I have a very simple terminal application that sens and receives characters from a serial port. This currently uses two fixed size TextBox controls, one beneath the other. I now would like to split the main window into two halves that keep their 50% size, with a TextBlock for a label and TextBox for characters in each half.

I suspect I could use the simple StackPanel for this, but how do I specify, in the inner stackpanels, that the label panel has a fixed height, and the text must fill the remaining height. How do I specify that the outer two panels each always occupy 50% of the height?

Answers


For the outer panels, use a Grid.

The InnerPanels can be done as a DockPanel (with LastChildFill=true)


Why don't you do:

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock Text="Title1"/><!-- You could use a Label control here instead-->
<TextBox />
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical">
<TextBlock Text="Title1"/><!-- You could use a Label control here instead-->
<TextBox />
</StackPanel>
</Grid>

Need Your Help

XSS Blacklist - Is anyone aware of a reasonable one?

javascript html security xss

As a temporary quick fix to mitigate the major risk while working on the permanent fix for XSS Vulnerability in a very large code base, I'm looking for a pre-existing XSS prevention blacklist that ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.