#283 – A Window Can Have Only a Single Child Element
April 21, 2011 Leave a comment
In WPF, a Window can have only a single child element. Window inherits from ContentControl, which is a control that contains a single child element, referenced by its Content property.
Your window might have a single simple child control, like a Button.
<Window> <Button Content="Big Daddy Button"/> </Window>
Since having a single control in your application is not very useful, it’s more common that the single child control of a Window is a container control like StackPanel, which in turn can contain multiple child elements.
<Window> <StackPanel> <Label Content="You can enter your name here:"/> <TextBox /> <Button Content="Push to Continue"/> </StackPanel> </Window>