[]
C1HeaderedContentControl's header bar is able to accept other control. In this topic, you will add a Button control to the header in XAML and in code.
In XAML
To add a Button control to the header in XAML, place the following XAML markup between the <c1:C1HeaderedContentControl>
and </c1:C1HeaderedContentControl>
tags:
<c1:C1HeaderedContentControl.Header>
<Button Content="Button" Height="Auto" Width="50"/>
</c1:C1HeaderedContentControl.Header>
In code
To add a Button control to the header in code, complete the following steps:
Add x:Name="C1HeaderedContentControl1"
to the <c1:C1HeaderedContentControl>
tag so that the control will have a unique identifier for you to call in code.
Enter Code view and add the following code beneath the InitializeComponent() method:
Visual Basic
'Create the Button control
Dim NewButton As New Button()
NewButton.Content = "Button"
'Set the Button Control's Width and Height properties
NewButton.Width = 50
NewButton.Height = [Double].NaN
'Add the Button to the header
C1HeaderedContentControl1.Header = (NewButton)
C#
//Create the Button control
Button NewButton = new Button();
NewButton.Content = "Button";
//Set the Button Control's Width and Height properties
NewButton.Width = 50;
NewButton.Height = Double.NaN;
//Add the Button to the header
C1HeaderedContentControl1.Header=(NewButton);
Run the Program.
This topic Illustrates the following:
As a result of this topic, a Button control will appear in the header bar. The final result will resemble the following image: