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

    You can easily create a C1Book control at design time, in XAML, and in code. Note that if you create a C1Book control as in the following steps, it will appear as an empty container. You will need to add items to the control for it to appear as a book at run time. For an example, see Adding Items to a Book.

    At Design Time

    To create a C1Book control, complete the following steps:

    1. Click once on the design surface of the Window to select it.
    2. Double-click the C1Book icon in the Toolbox to add the control to the panel. The C1Book control will now exist in your application.

    If you choose, you can customize the control by selecting it and setting properties in the Properties window.

    In XAML

    To create a C1Book control using XAML markup, complete the following steps:

    1. In the Visual Studio Solution Explorer, right-click the References folder in the project files list. In the context menu choose Add Reference, select the C1.WPF.dll and C1.WPF.Extended.dll assemblies, and click OK.
    2. Add a XAML namespace to your project by adding xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" to the initial <Window> tag. It will appear similar to the following:
    XAML
    Copy Code
    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" x:Class="Window1" Title="Window1" Height="230" Width="348">
    

     

    1. Add a <c1:C1Book> tag to your project within the <Grid> tag to create a C1Book control. The markup will appear similar to the following:
    XAML
    Copy Code
    <Grid>
        <c1:C1Book x:Name="C1Book1" Height="300" Width="450"/>
        </c1:C1Book>
    </Grid>
    

     

    This markup will create an empty C1Book control named "C1Book1" and set the control's size.

    In Code

    To create a C1Book control in code, complete the following steps:

    1. In the Visual Studio Solution Explorer, right-click the References folder in the project files list. In the context menu choose Add Reference, select the C1.WPF.dll and C1.WPF.Extended.dll assemblies, and click OK.
    2. In XAML view, give the initial grid in the window a name, by updating the tag so it appears similar to the following:

    <Grid x:Name="LayoutRoot">

    1. Right-click within the Window1.xaml window and select View Code to switch to Code view.
    2. Add the following import statements to the top of the page:
    Visual Basic
    Copy Code
    Imports C1.WPF
    Imports C1.WPF.Extended
    

    C#
    Copy Code
    using C1.WPF;
    using C1.WPF.Extended;
    

     

    1. Add code to the page's constructor to create the C1Book control. It will look similar to the following:

    Visual Basic
    Copy Code
    Public Sub New()
        InitializeComponent()
        Dim c1book1 as New C1Book
        c1book1.Height = 300
        c1book1.Width = 450
        LayoutRoot.Children.Add(c1book1)
    End Sub
    

    C#
    Copy Code
    public MainPage()
    {
        InitializeComponent();
        C1Book c1book1 = new C1Book();
        c1book1.Height = 300;
        c1book1.Width = 450;
        LayoutRoot.Children.Add(c1book1);
    }
    

     

    This code will create an empty C1Book control named "c1book1", set the control's size, and add the control to the page.

    What You've Accomplished

    You've created a C1Book control. Note that when you create a C1Book control as in the above steps, it will appear as an empty container. You will need to add items to the control for it to appear as a book at run time. For an example, see Adding Items to a Book.