Content Model : GroupBox Headers other than just a plain text in WPF

How to have a Group box in WPF / XAML with a header other than just plain text?

We know that  WPF / XAML supports Content Model that allows us to have elements arranged in a way that makes it possible to have anything to be used as a caption!
It could be just a plain text or some graphics or some data aswell.

For example,


<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

  <Grid>
<GroupBox>
    <GroupBox.Header>
          <StackPanel Orientation="Horizontal">
                       <Button><TextBlock Text="Click Me!" /></Button>
          </StackPanel>
    </GroupBox.Header>
</GroupBox>
 </Grid>

</Page>

Here in the xaml above, the groupbox header is not just a plain text , it is a button with the text Click Me! in it, this is done within the <GroupBox.Header> </GroupBox.Header>

1 comment: