Adding the Components to the Page

In the XAML view, replace the Grid with a DockPanel control like shown in the below screenshot:

In the next steps, the order in how the controls are added to the Page is important.

Double-click the ButtonBar in the toolbox to add it to the Page. Repeat this for the RulerBar, StatusBar, a second RulerBar and finally TextControl. The XAML should look like this:

Visual Studio 2008 users: In the XAML, remove the Height and the Width properties for all added elements.

Select the secondly added Ruler Bar rulerBar2 using the mouse in the Design view to change the properties in the Properties window. Browse for the DockPanel.Dock property and change it to Left.

Additionally, set the HorizontalAlignment to Left and the VerticalAlignment to Stretch. The Design view should look like this:

Now, the controls must be connected. Therefore, select textControl1 to open it's properties in the Properties window of Visual Studio. First, look for ButtonBar property and type in the name of the added Button Bar: buttonBar1.

Set the RulerBar property to rulerBar1, StatusBar to statusBar1 and VerticalRulerBar to rulerBar2.

In the XAML, add the Loaded="textControl1_Loaded" event handler to the TextControl element as a parameter, so that the line looks like this:

<my:TextControl Name="textControl1" Loaded="textControl1_Loaded"
    ButtonBar="buttonBar1" StatusBar="statusBar1" RulerBar="rulerBar1" VerticalRulerBar="rulerBar2"/>

Now, right-click on textControl1_Loaded and choose Navigate to Event Handler from the opened context menu. Add the following code to the event handler:

private void textControl1_Loaded(object sender, RoutedEventArgs e)
[Visual Basic]
private void textControl1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)

Open the project properties using by selecting the Properties... menu item from Project main menu. On the Security tab page, make sure that the check box Enable ClickOnce Security Settings is checked and choose This is a full trust application.

Now, press F5 to compile and start the application:

<< Previous Next >>