This walkthrough shows how to add various button types to UXToolBar using designer tools available in Visual Studio 2010.
In this walkthrough, you perform the following tasks:
-
Create a new ClientUI Silverlight project.
-
Add a new tool bar to the designer surface.
-
Add button, split button and dropdown button to the tool bar using Visual Studio designer.
Prerequisites
You need the following components to complete this walkthrough:
- Visual Studio 2010
- Silverlight 4 Tools for Visual Studio 2010
- Intersoft ClientUI
Creating a new ClientUI Application Project
The first step is to create a new ClientUI Application project using Intersoft ClientUI Application project template in Visual Studio.
To create the ClientUI Application project
- Start Visual Studio 2010.
- Create a new ClientUI Application project using Intersoft ClientUI Application project template. To learn more, see Walkthrough: Create New Intersoft ClientUI Application Template.
To add the resources file
- In your project, create new folder with name Assets.
- In Assets folder, create new folder with name Images.
- In Images folder, copy the images from [Intersoft Installation Folder]Intersoft WebUI Studio 2010 R1\Samples\SL4\ClientUI Samples\Intersoft.ClientUI.Samples.Assets\Images\Office\.
Creating The Application Interface
This section show how to add button, splitbutton and drodpwn button to UXToolBar using designer.
To add button, splitbutton and dropdown button to UXToolBar using designer.
- Open the Toolbox window if it is not already open.
- From the Toolbox, Double-click the UXWindow control.
- Right-click the UXWindow, click Reset Layout, and then click Alignments and Margin.
- Select the UXWindow.
- Locate the IsClientVisible property in the Properties window or you can filter the properties in the search box.
- Set the IsClientVisible property to True.
- Still on UXWindow, set the Width and Height properties to 500 and 300.
- Double-click a DockPanel within the UXWindow element.
- Double-click the UXToolBar control just under the DockPanel control, but within the UXWindow.
- Set the dock position to Dock to Top by clicking the top square of the icon indicator.
- Right-click the UXToolBar, click Reset Layout, and then click All.
- Remove / delete the two predefined toolbar buttons when you insert the toolbar.
- Add the Dropdown Button within the toolbar.
- Set the Content property of UXToolBarButton to Style.
- Add the UXMenuItem within the Style toolbar by right-click on the Style toolbar, click Add Item.
- Set the Content and Icon properties of the new created UXToolBarButton to Bold and boldhs.png.
- Add one additional MenuItem and set the Content and Icon properties of UXToolBarButton to Italic and ItalicHS.png.
- Add a UXSeparator by right-click on the toolbar, click Add Item to Group, click Add Separator.
- Add an Image Button by right-click on the toolbar, click Add Item to Group, click Add Image Button.
- Set the Icon property of the new created Image Button to CutHS.png.
- Add two additional Image Button and set the Icon property of UXToolBarButton to CopyHS.png and PasteHS.png.
- Add another separator.
- Add the Split Button within the toolbar by right-click on the toolbar, click Add Item to Group, click Add Split Button.
- Set the Content property of Split Button to Print.
- Add two additional MenuItem within the Split Button.
- Set the Content and Icon properties of the first MenuItem to Print Area and PrintArea.png.
- Set the Content and Icon properties of the second MenuItem to Print Preview and PrintPreviewHS.png.
- Double-click the xtBox control just under the DockPanel control, but within the UXWindow.
- Set the dock position to Stretch to Fill by click the middle square of the icon indicator.
- Run the project.
Complete Code Listing
MainPage.xaml
MainPage | ![]() |
---|---|
<Intersoft:UXPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:Intersoft="http://intersoft.clientui.com/schemas" x:Class="AddButtontoToolBar.MainPage" Title="MainPage Page" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot"> <Intersoft:UXWindow Header="UXWindow Title" Height="300" Name="uXWindow1" Width="500" IsClientVisible="True"> <Grid> <Intersoft:DockPanel Name="dockPanel1" FillChildMode="Custom"> <Intersoft:UXToolBar Name="uXToolBar1" Intersoft:DockPanel.Dock="Top"> <Intersoft:UXToolGroup> <Intersoft:UXToolBarButton Content="Style" ButtonType="DropdownButton"> <Intersoft:UXMenuItem Header="Bold" Icon="/AddButtontoToolBar;component/Assets/Images/boldhs.png" /> <Intersoft:UXMenuItem Header="Italic" Icon="/AddButtontoToolBar;component/Assets/Images/ItalicHS.png" /> </Intersoft:UXToolBarButton> <Intersoft:UXSeparator Name="uXSeparator1" /> <Intersoft:UXToolBarButton Name="uXToolBarButton1" Icon="/AddButtontoToolBar;component/Assets/Images/CutHS.png" DisplayMode="Image" /> <Intersoft:UXToolBarButton Name="uXToolBarButton2" Icon="/AddButtontoToolBar;component/Assets/Images/CopyHS.png" DisplayMode="Image" /> <Intersoft:UXToolBarButton Name="uXToolBarButton3" Icon="/AddButtontoToolBar;component/Assets/Images/PasteHS.png" DisplayMode="Image" /> <Intersoft:UXSeparator Name="uXSeparator2" /> <Intersoft:UXToolBarButton ButtonType="SplitButton" Content="Print" Name="uXToolBarButton4" Icon="/AddButtontoToolBar;component/Assets/Images/PrintHS.png" DisplayMode="ContentAndImage"> <Intersoft:UXMenuItem Header="Print Area" Icon="/AddButtontoToolBar;component/Assets/Images/PrintArea.png" /> <Intersoft:UXMenuItem Header="Print Preview" Icon="/AddButtontoToolBar;component/Assets/Images/PrintPreviewHS.png" /> </Intersoft:UXToolBarButton> </Intersoft:UXToolGroup> </Intersoft:UXToolBar> <RichTextBox Name="richTextBox1" Intersoft:DockPanel.IsFillElement="True" /> </Intersoft:DockPanel> </Grid> </Intersoft:UXWindow> </Grid> </Intersoft:UXPage> |