Adding a Control to the Content Area

The C1Expander control will accept one child control in its content area. In this topic, you will learn how to add a Silverlight button control in Blend, in XAML, and in code.

At Design Time in Blend

To add a control to the content area, complete the following steps:

1.   Navigate to the Assets tab and expand the Controls node.

2.   Select All to open a list of all available Silverlight controls.

3.   Select the Button icon and use a drag-and-drop operation to add it to the content area of the C1Expander control.

4.   Under the Objects and Timeline tab, select [Button] so that the Button control's properties take focus in the Properties tab. 

5.   Next to the Width property, click the Set to Auto button SetToAuto.png. This will ensure that the height of the button control is the same height as the C1Expander control's content area.

6.   Next to the Height property, click the Set to Auto button SetToAuto.png. This will ensure that the height of the button control is the same height as the C1Expander control's content area.

7.   Run the program and then expand the C1Expander control.

In XAML

To add a button control to the C1Expander control's content area in XAML, complete the following steps:

1.   Place the following markup between the <c1:C1Expander> and </c1:C1Expander> tags:

 

<Button Content="Button" Height="Auto" Width="Auto"/>

 

2.   Run the program and then expand the C1Expander control.

In Code

To add a button control to the C1Expander control's content area in code, complete the following:

1.   Add x:Name="C1Expander1" to the <c1:C1Expander> tag so that the control will have a unique identifier for you to call in code. 

2.   Enter Code view and add the following code beneath the InitializeComponent() method:

      Visual Basic

      C#

3.   Run the program and then expand the C1Expander control.

 This Topic Illustrates the Following:

When the C1Expander control is expanded, the button control appears in its content area and resembles the following image:

 


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.