Extended Library for WPF and Silverlight | ComponentOne
Book / C1Book Task-Based Help / Adding Items to a Book
In This Topic
    Adding Items to a Book
    In This Topic

    ou can add any sort of arbitrary content to a C1Book control. This includes text, images, layout panels, and other standard and 3rd-party controls. In this example, you'll add a TextBlock control to a C1Book control, but you can customize the steps to add other types of content instead.

    At Design Time

    To add a TextBlock control to the book, complete the following steps:

    1. Click the C1Book control once to select it.
    2. Navigate to the Toolbox, and double-click the TextBlock item to add the control to the C1Book control.
    3. If you choose, you can customize the C1Book and TextBlock controls by selecting each control and setting properties in the Properties window. For example, set the TextBlock's Text property to "Hello World!".

    In XAML

    For example, to add a TextBlock control to the book add <TextBlock Text="Hello World!"/> within the <c1:C1Book> tag so that it appears similar to the following:

    XAML
    Copy Code
    <c1:C1Book x:Name="C1Book1" Height="300" Width="450">
        <TextBlock Text="Hello World!"/>
    </c1:C1Book>
    

     

    In Code

    For example, to add a TextBlock control to the book, add code to the page's constructor so it appears like the following:

    Visual Basic
    Copy Code
    Public Sub New()
        InitializeComponent()
        Dim txt1 as New TextBlock
        txt1.Text = "Hello World!"
        C1Book1.Items.Add(txt1)
    End Sub
    
    C#
    Copy Code
    public MainPage()
    {
        InitializeComponent();
        TextBlock txt1 = new TextBlock();
        txt1.Text = "Hello World!";
        c1Book1.Items.Add(txt1);
    }
    

     

    What You've Accomplished

    You've added a control to the C1Book control. Run the application and observe that the TextBlock control has been added to the C1Book control. You can similarly add other content and controls.