This walkthrough shows how to add a variety of button types to UXToolBar using designer tools available in Expression Blend.
In this walkthrough, you perform the following tasks:
-
Create a new Silverlight project.
-
Add a new tool bar to the designer surface.
-
Add button, split button and dropdown button to the tool bar using Expression Blend designer.
Prerequisites
You need the following components to complete this walkthrough:
-
Microsoft Expression Blend 4
-
Intersoft ClientUI
Creating New Silverlight Application and Website Project
The first step is to create a new Silverlight Application and Website project in Microsoft Expression Blend 4.
To create a new Silverlight application and Website project
-
Start Microsoft Expression Blend 4.
-
Create a new Silverlight project using the Silverlight Application + Website project template. Name the project as AddMenuItemAndSeparatorToMenuBarInBlendDesigner.
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
To create Button, DropDownButton and SplitButton to ToolBarButton in Blend Designer
- Open the MainPage.xaml.
- In Tools Panel, click the Assets, type the UXWindow inside the search box, click on the UXWindow icon.
- The UXWindow will be appear down the Assets tools, double-click the UXWindow icon. Make sure you have selected the LayoutRoot under [UserControl].
- In the Properties panel, under Layout, reset the margin property by click the white square and click Reset.
- Set the IsClientVisible property to True
- Add a DockPanel within the UXWindow.
- Set the Width and Height property to Auto.
- Set the HorizontalAlignment and VerticalAlignment properties of DockPanel to Stretch.
- Add the UXToolBar under DockPanel, within the UXWindow.
- Set the dock position to Dock to Top by clicking the top square of the icon indicator.
- Remove / delete the two predefined toolbar buttons when you insert the toolbar.
- Add a Dropdown Button by right-click on the toolbar, click Add Item to Group, click Add Dropdown Button.
- Add the UXMenuItem control within the UXToolBar by right-click on the toolbar, click Add Menu Item.
- Under Common Properties, set the Header property to Bold and the Icon property to boldhs.png.
- Add one additional UXMenuItem within the toolbar.
- Set the Header and Icon properties of new created UXMenuItem to Italic and ItalicHS.png.
- Select the UXToolBar and add the 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.
- Under Common Properties, set the Icon property to CutHS.png.
- Add two additional UXToolBarButton and set the Icon property for each toolbar button to CopyHS.png and PasteHS.png.
- Add another UXSeparator.
- Add the Split Button 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 UXMenuItem within the Split Button.
- Set the first UXMenuItem Header and Icon properties to Print Area and PrintArea.png.
- Set the second UXMenuItem Header and Icon properties to Print Preview and PrintPreviewHS.png.
- Run the project.
In this walkthrough, you have learned how to create the UXToolBar and add the UXToolBarButton and UXSeparator in Microsoft Expression Blend Designer.
Complete Code Listing
MainPage.xaml
MainPage | ![]() |
---|---|
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Intersoft="http://intersoft.clientui.com/schemas" x:Class="AddtoToolBar.MainPage" Width="640" Height="480"> <Grid x:Name="LayoutRoot" Background="White"> <Intersoft:UXWindow Header="UXWindow Title" IsClientVisible="True"> <Grid> <Intersoft:DockPanel> <Intersoft:UXToolBar Intersoft:DockPanel.Dock="Top"> <Intersoft:UXToolGroup> <Intersoft:UXToolBarButton Content="Style" ButtonType="DropdownButton"> <Intersoft:UXMenuItem Header="Bold" Icon="Assets/Images/boldhs.png"/> <Intersoft:UXMenuItem Header="Italic" Icon="Assets/Images/ItalicHS.png"/> </Intersoft:UXToolBarButton> <Intersoft:UXSeparator/> <Intersoft:UXToolBarButton Content="UXToolBarButton" DisplayMode="Image" Icon="Assets/Images/CutHS.png"/> <Intersoft:UXToolBarButton Content="UXToolBarButton" DisplayMode="Image" Icon="Assets/Images/CopyHS.png"/> <Intersoft:UXToolBarButton Content="UXToolBarButton" DisplayMode="Image" Icon="Assets/Images/PasteHS.png"/> <Intersoft:UXSeparator/> <Intersoft:UXToolBarButton ButtonType="SplitButton" Content="Print" Icon="Assets/Images/PrintHS.png" DisplayMode="ContentAndImage"> <Intersoft:UXMenuItem Header="Print Area" Icon="Assets/Images/PrintArea.png"/> <Intersoft:UXMenuItem Header="Print Preview" Icon="Assets/Images/PrintPreviewHS.png"/> </Intersoft:UXToolBarButton> </Intersoft:UXToolGroup> </Intersoft:UXToolBar> </Intersoft:DockPanel> </Grid> </Intersoft:UXWindow> </Grid> </UserControl> |