Using the Application Bar

ComponentOne RichTextBox for Windows phone includes a  C1.Phone.RichTextBox.ApplicationBar assembly containing an application bar that you can add buttons to for use in your application. There is no visible application bar control; however, you can add the C1 Tools included in the assembly to the application bar. All you need to do is specify the IconUri path for the button icons and set each image's Build Action property to Content.

To add buttons to the application bar, follow these steps:

1.   Create an Images folder containing images to be used for the button icons.

2.   In the Solution Explorer, click Show All Files, right-click the Images folder, and select Include In Project.

3.   Select each image and in the Visual Studio Properties window, set the Build Action to Content.

4.   Add a C1RichTextBox control to the page.

5.   In the Solution Explorer, right-click the References folder, select Add Reference and select C1.Phone.RichTextBox.ApplicationBar.dll.

6.   Add the following namespace to the list of namespaces at the top of the XAML page:

xmlns:c1="clr-namespace:C1.Phone.RichTextBox;assembly=C1.Phone.RichTextBox.ApplicationBar"

7.   Add XAML markup for the ApplicationBar and ApplicationBarIconButtons. Notice that the first button is simply an ApplicationBarIconButton and  the second button creates a C1ItalicTool.

<!--Sample code showing usage of ApplicationBar-->

    <phone:PhoneApplicationPage.ApplicationBar>

      <shell:ApplicationBar>

        <shell:ApplicationBarIconButton IconUri="Images/appbar_button1.png" Text="Button 1"/>

            <c1:C1ItalicTool IconUri="Images/ItalicButton.png" />

 

            </shell:ApplicationBar>

    </phone:PhoneApplicationPage.ApplicationBar>

8.   Select the C1ItalicTool XAML, and in the Properties window, set the RichTextBox property to C1RichTextBox.

9.   Select View | Code to switch to code view, and enter the following code so that when a user taps the italic button, italics are applied to the selected text:

public MainPage()

{

    InitializeComponent();

    ((C1ItalicTool)this.ApplicationBar.Buttons[1]).RichTextBox = c1RichTextBox1;

}

10.  Press F5 to run the application, select some text, and tap the italics button.

 

 


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