- Release Notes
- Overview
- Getting Started
- Marketplace Vendors
- Marketplace Customers
- Publishing Guidelines
- Publishing Guidelines for Ready-to-go Automations
- Publishing Guidelines for Solution Accelerators
- Publishing Guidelines for Integration Service Connectors
- Security & IP Protection
- Other UiPath Listings
- Node-RED
- Setup
- Teams
- Microsoft Teams Scope
- Create Team
- Create Team From Group
- Get Team
- Get Teams
- Channels
- Create Channel
- Delete Channel
- Get Channel
- Get Channels
- Update Channel
- Chats
- Get Chat
- Get Chats
- Get Chat Members
- Messages
- Get Message
- Get Messages
- Get Message Replies
- Reply To Message
- Send Message
- Events
- Create Event
- Delete Event
- Get Event
- Get Events
- Users
- Get User Presence
- How It Works
- Technical References
- Get Started
- About
- Setup
- Technical References
- Azure Form Recognizer Scope
- Activities
- Analyze Form
- Analyze Form Async
- Get Analyze Form Result
- Analyze Receipt
- Analyze Receipt Async
- Get Analyze Receipt Result
- Analyze Layout
- Analyze Layout Async
- Get Analyze Layout Result
- Train Model
- Get Models
- Get Model Keys
- Get Model Info
- Delete Model
- Connectors
- How to Create Activities
- Build Your Integration
The Designer File
Intro
A complete activity may be created with the activity definition file alone, but the user experience is almost always enhanced by adding a designer, or UI. Designers are written in XAML, an XML-based language (described in more detail here), and used to create front-ends for Windows Presentation Foundation (WPF) applications.
Navigate to the ChildActivityDesigner.xaml file and walk through section by section to better understand how to enhance your activity with a UI.
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:converters="clr-namespace:UiPath.Shared.Activities.Design.Converters">
<a href="sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\)\)Themes\)\)Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:ActivityIconConverter x:Key="ActivityIconConverter" />
</ResourceDictionary>
</sap:ActivityDesigner.Resources>
<a href="sap:ActivityDesigner.Icon">sap:ActivityDesigner.Icon</a>
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\)\),\)\),\)\),/MyCompany.MyProduct.Activities.Design;component/themes/icons.xaml}" />
</sap:ActivityDesigner.Icon>
</sap:ActivityDesigner>
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:converters="clr-namespace:UiPath.Shared.Activities.Design.Converters">
<a href="sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\)\)Themes\)\)Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:ActivityIconConverter x:Key="ActivityIconConverter" />
</ResourceDictionary>
</sap:ActivityDesigner.Resources>
<a href="sap:ActivityDesigner.Icon">sap:ActivityDesigner.Icon</a>
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\)\),\)\),\)\),/MyCompany.MyProduct.Activities.Design;component/themes/icons.xaml}" />
</sap:ActivityDesigner.Icon>
</sap:ActivityDesigner>
All designers contain one top-level component in which a class is declared and supplemental namespaces are imported. This example extends the ActivityDesigner class, the base class for all such components.
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:converters="clr-namespace:UiPath.Shared.Activities.Design.Converters">
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:converters="clr-namespace:UiPath.Shared.Activities.Design.Converters">
xmlns:<prefix>
. These
prefixes are used later on in the file to reference useful
components.
Resources are reusable components, styles, or data made available for use in a XAML file via a ResourceDictionary component. In this example, two types of resources are provided--a dictionary of styles (Generic.xaml) and a converter component (ActivityIconConverter).
<a href="sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\)\)Themes\)\)Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:ActivityIconConverter x:Key="ActivityIconConverter" />
</ResourceDictionary>
</sap:ActivityDesigner.Resources>
<a href="sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\)\)Themes\)\)Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:ActivityIconConverter x:Key="ActivityIconConverter" />
</ResourceDictionary>
</sap:ActivityDesigner.Resources>
-
Generic.xaml is another
ResourceDictionary
containing standard UiPath styles that help keep the look of designers consistent. Peeking inside this file, you see the following style, which sets a standard height for allComboBox
objects. Because we've included this dictionary in our XAML file, all comboboxes will have a default height of 23px.<Style TargetType="{x:Type ComboBox}"> <Setter Property="Height" Value="23" /> </Style>
<Style TargetType="{x:Type ComboBox}"> <Setter Property="Height" Value="23" /> </Style> -
ActivityIconConverter is a utility class that is provided through the Shared folder and which allows all activity icons to be specified in a standard way. See the Icons section below for more details.
Icons, like those seen on all UiPath activities, may be added directly to a Designer file in XAML format, but our preferred method is to add them all in one dedicated file and use the aforementioned ActivityIconConverter to pull them into each activity. In this way, the main Designer file remains uncluttered by often long icon code.
Within your Design project, navigate to Themes > Icons.xaml.
x:Key
attribute, which takes the form <Activity
Name>Icon
. The Child Activity's icon code, for example, has the
following format:
<DrawingBrush x:Key="ChildActivityIcon" Viewbox="0,0,52.706,14.497" ViewboxUnits="Absolute" Stretch="Uniform">
...
</DrawingBrush>
<DrawingBrush x:Key="ChildActivityIcon" Viewbox="0,0,52.706,14.497" ViewboxUnits="Absolute" Stretch="Uniform">
...
</DrawingBrush>
ConverterParameter
references your
Designer project by name.
<a href="sap:ActivityDesigner.Icon">sap:ActivityDesigner.Icon</a>
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\)\),\)\),\)\),/MyCompany.MyProduct.Activities.Design;component/themes/icons.xaml}" />
</sap:ActivityDesigner.Icon>
<a href="sap:ActivityDesigner.Icon">sap:ActivityDesigner.Icon</a>
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\)\),\)\),\)\),/MyCompany.MyProduct.Activities.Design;component/themes/icons.xaml}" />
</sap:ActivityDesigner.Icon>
Adding components
You now have the foundation of a designer, but it's still completely blank! Let's expand upon this by adding two textfields, one for each of the Child Activity's inputs.
ActivityDecoratorControl
to your designer immediately below your
icon code. Visual Studio may prompt you to import the
UiPath.Shared.Activities.Design.Controls
namespace, but if not, add
this to the class definition at the top of the file as well.
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
...
xmlns:controls="clr-namespace:UiPath.Shared.Activities.Design.Controls">
<?comment-start?>
Resources
<?comment-end?>
<?comment-start?>
Icons
<?comment-end?>
<controls:ActivityDecoratorControl Style="{StaticResource ActivityDecoratorStyle}">
</controls:ActivityDecoratorControl>
</sap:ActivityDesigner>
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
...
xmlns:controls="clr-namespace:UiPath.Shared.Activities.Design.Controls">
<?comment-start?>
Resources
<?comment-end?>
<?comment-start?>
Icons
<?comment-end?>
<controls:ActivityDecoratorControl Style="{StaticResource ActivityDecoratorStyle}">
</controls:ActivityDecoratorControl>
</sap:ActivityDesigner>
ActivityDecoratorControl
, which provides standard activity
behaviors such as the ability to minimize a large designer and display the message
"Double click to view." in its place. Details like this are small but combine to give a
UiPath feel to the overall activity package.
Rebuild your package and you'll see that it now looks slightly different:
Next, let's set the layout of the activity so it can display labels and text fields in an appealing way. WPF has 6 main layouts, but we're going to use a Grid panel to hold our controls. The Grid works by first defining a number of rows and columns along with their heights and widths respectively. Start by defining 2 rows and 2 columns.
<controls:ActivityDecoratorControl Style="{StaticResource ActivityDecoratorStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
</Grid>
</controls:ActivityDecoratorControl>
<controls:ActivityDecoratorControl Style="{StaticResource ActivityDecoratorStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
</Grid>
</controls:ActivityDecoratorControl>
RowDefinition
heights are both *
so they will
consume as much vertical space as exists. The ColumnDefinition
widths,
however, are *
and 3*
, meaning the first column will
consume 25% of any available whitespace along the width and the second column 75%.
Now that the layout is set, we'll add two textboxes with which the user can access the Child Activity's two input properties--First Number and Second Number. Start by adding a Label after the Grid definitions for the First Number.
Label
:
- Grid.Row: Positions the label in the first row of the Grid defined above.
- Grid.Column: Positions the label in the first column of the Grid defined above.
- Content: Sets the text that appears in the label.
See here for a complete list of properties available to WPF elements.
<Grid>
<?comment-start?>
Grid definitions
<?comment-end?>
<Label Grid.Row="0" Grid.Column="0"
Content="First Number" />
</Grid>
<Grid>
<?comment-start?>
Grid definitions
<?comment-end?>
<Label Grid.Row="0" Grid.Column="0"
Content="First Number" />
</Grid>
Next, let's add an ExpressionTextBox to allow for user input. If Visual Studio does not prompt you to do so, you must manually add two more namespaces to the class definition.
xmlns:view="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:view="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:system="clr-namespace:System;assembly=mscorlib"
ExpressionTextBox
:
- Grid.Row: Positions the label in the first row of the Grid defined above.
- Grid.Column: Positions the label in the second column of the Grid defined above.
- HintText: Sets the tooltip text that appears within the textbox when empty and also when the user's mouse hovers over this field.
-
ExpressionType: Sets the type of data that is allowed in this field. Since our property is a number of type
int
, this is set toInt32
.<Grid> <?comment-start?> Grid definitions <?comment-end?> <Label Grid.Row="0" Grid.Column="0" Content="First Number" /> <view:ExpressionTextBox Grid.Row="0" Grid.Column="1" HintText="The first addend" ExpressionType="system:Int32" /> </Grid>
<Grid> <?comment-start?> Grid definitions <?comment-end?> <Label Grid.Row="0" Grid.Column="0" Content="First Number" /> <view:ExpressionTextBox Grid.Row="0" Grid.Column="1" HintText="The first addend" ExpressionType="system:Int32" /> </Grid>
Rebuild your package and it should now look like this:
Label
and
ExpressionTextBox
for the Second Number
property, remembering that these controls will now be in
Grid.Row="1"
. The final result should look like
this:
String
inputs, ExpressionTextBoxes allow the user to enter
complex VB.Net expressions (e.g. Int32.MaxValue
, 2+2
,
SomeUiPathVariable
) and can bind this value to a property in your
activity.
ExpressionTextBox
:
- OwnerActivity: Specifies a ViewModel used by the designer to link to the activity file. For our purposes, this will always be ModelItem.
- Expression: Supplies the activity property to which this field will be bound. There are 4 main components here:
- Binding: Specifies by name the activity
property to which to bind. If the
ModelItem
holds your activity's contents,ModelItem.FirstNumber
links directly to the First Number property. - Converter: Provides a class to convert between
objects of different types. In our case, the designer field holds an
int
, but the activity property is of typeInArgument<int>
, so we add a standardArgumentToExpressionConverter
to handle the binding between them. - ConverterParameter: Specifies the type of
argument to which this field is bound. In this case, we are binding to
InArgument<>
properties, so the ConverterParameter isIn
, butInOut
andOut
are options as well. - Mode: Indicates whether changes in the designer
field will trigger updates or the activity property and vice versa. Set this as
TwoWay
to allow the user to update either the designer or the properties pane. See here for all other options.
ArgumentToExpressionConverter
by adding the following line to your
ResourceDictionary
and importing the
clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation
namespace in your class definition.
<converters1:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
<converters1:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
All together, your Child Activity designer and code should appear as below. Enter values into each field and notice how the corresponding properties update.
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:converters="clr-namespace:UiPath.Shared.Activities.Design.Converters"
xmlns:converters1="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
xmlns:controls="clr-namespace:UiPath.Shared.Activities.Design.Controls"
xmlns:view="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<a href="sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\)\)Themes\)\)Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters1:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
<converters:ActivityIconConverter x:Key="ActivityIconConverter" />
</ResourceDictionary>
</sap:ActivityDesigner.Resources>
<a href="sap:ActivityDesigner.Icon">sap:ActivityDesigner.Icon</a>
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\)\),\)\),\)\),/MyCompany.MyProduct.Activities.Design;component/themes/icons.xaml}" />
</sap:ActivityDesigner.Icon>
<controls:ActivityDecoratorControl Style="{StaticResource ActivityDecoratorStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0"
Content="First Number" />
<view:ExpressionTextBox Grid.Row="0" Grid.Column="1"
OwnerActivity="{Binding Path=ModelItem}"
ExpressionType="system:Int32"
HintText="The first addend"
Expression="{Binding Path=ModelItem.FirstNumber,Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In, Mode=TwoWay}" />
<Label Grid.Row="1" Grid.Column="0"
Content="Second Number" />
<view:ExpressionTextBox Grid.Row="1" Grid.Column="1"
OwnerActivity="{Binding Path=ModelItem}"
ExpressionType="system:Int32"
HintText="The second addend"
Expression="{Binding Path=ModelItem.SecondNumber,Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In, Mode=TwoWay}" />
</Grid>
</controls:ActivityDecoratorControl>
</sap:ActivityDesigner>
<sap:ActivityDesigner x:Class="MyCompany.MyProduct.Activities.Design.ChildActivityDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:converters="clr-namespace:UiPath.Shared.Activities.Design.Converters"
xmlns:converters1="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
xmlns:controls="clr-namespace:UiPath.Shared.Activities.Design.Controls"
xmlns:view="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<a href="sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\)\)Themes\)\)Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters1:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
<converters:ActivityIconConverter x:Key="ActivityIconConverter" />
</ResourceDictionary>
</sap:ActivityDesigner.Resources>
<a href="sap:ActivityDesigner.Icon">sap:ActivityDesigner.Icon</a>
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\)\),\)\),\)\),/MyCompany.MyProduct.Activities.Design;component/themes/icons.xaml}" />
</sap:ActivityDesigner.Icon>
<controls:ActivityDecoratorControl Style="{StaticResource ActivityDecoratorStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0"
Content="First Number" />
<view:ExpressionTextBox Grid.Row="0" Grid.Column="1"
OwnerActivity="{Binding Path=ModelItem}"
ExpressionType="system:Int32"
HintText="The first addend"
Expression="{Binding Path=ModelItem.FirstNumber,Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In, Mode=TwoWay}" />
<Label Grid.Row="1" Grid.Column="0"
Content="Second Number" />
<view:ExpressionTextBox Grid.Row="1" Grid.Column="1"
OwnerActivity="{Binding Path=ModelItem}"
ExpressionType="system:Int32"
HintText="The second addend"
Expression="{Binding Path=ModelItem.SecondNumber,Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In, Mode=TwoWay}" />
</Grid>
</controls:ActivityDecoratorControl>
</sap:ActivityDesigner>