WPF and Silverlight Edition Basic Library > HeaderedContentControl > HeaderedContentControl for WPF and Silverlight Task- Based Help > Adding Content to the Content Panel > Adding Text to the Content Panel |
You can easily add a simple line of text to the content panel of C1HeaderedContentControl by setting the Content property to a string in Visual Studio, in XAML, or in code.
Note: You can also add text to the content panel by adding a TextBox control to the content panel and then setting the TextBox control's Text property. To learn how to add a control to the content panel, see Adding a Control to the content panel. |
At Design Time
To set the Content property in Visual studio, complete the following steps:
In XAML
To set the Content property in XAML, complete the following steps:
Add Content="This is Content Panel"
to the <c1:C1HeaderedContentControl>
tag so that it appears similar to the following:
<c1:C1HeaderedContentControl Content="This is Content Panel" Width="150" Height="55">
Run the program and then expand C1HeaderedContentControl.
In Code
To set the Content property in code, complete the following steps:
x:Name="C1HeaderedContentControl_Ct"
to the <c1:C1HeaderedContentControl>
tag so that the control will have a unique identifier for you to call in code.Visual Basic
C1HeaderedContentControl_Ct.Content = "This is Content Panel"
C#
C1HeaderedContentControl_Ct.Content = "This is Content Panel";
Run the program and then expand C1HeaderedContentControl.
This Topic Illustrates the Following:
When C1HeaderedContentControl is expanded, it reads "Hello World". The end result of this topic should resemble the following:
Note that there isn't a header; this is because the Header property isn't set by default. To learn how to add text or controls to the header bar, see Adding Content to the Header Bar.