I am trying to create a custom activity in the visual studio for UiPath.
My visual studio code contains an ActivityDesigner for the interface. I have created that, but I cannot get value from the Combobox to the main file where the execution function is written.
ActivityDesigner.xaml
<sap:ActivityDesigner x:Class="AchalSharma.ActivityDesigner1"
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:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
xmlns:c="clr-namespace:AchalSharma">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width = "Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height = "*" />
<RowDefinition Height = "*" />
<RowDefinition Height = "*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row = "0" Grid.Column = "0" Text = "Retrieve" Margin = "5" HorizontalAlignment = "Left" VerticalAlignment = "Center" Width = "70" />
<ComboBox Grid.Row = "0" Grid.Column = "1" Margin = "5" Name="Retrieve" HorizontalAlignment="Left" VerticalAlignment="Top" Width="153">
<ComboBoxItem Content="Current Date and Time" IsSelected="True"></ComboBoxItem>
<ComboBoxItem Content="Current Date"></ComboBoxItem>
</ComboBox>
<TextBlock Grid.Row = "1" Grid.Column = "0" Text = "Time Zone" Margin = "5" HorizontalAlignment = "Left" VerticalAlignment = "Center" Width = "70"/>
<ComboBox Grid.Row = "1" Grid.Column = "1" Margin = "5" Name="TimeZone" HorizontalAlignment="Left" VerticalAlignment="Top" Width="153">
<ComboBoxItem Content="System Time Zone" IsSelected="True"></ComboBoxItem>
<ComboBoxItem Content="Specific Time Zone"></ComboBoxItem>
</ComboBox>
</Grid>
</sap:ActivityDesigner>
Class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using System.ComponentModel;
namespace AchalSharma.DateAndTime
{
public class GetCurrentDateAndTime : CodeActivity
{
[Category("Input")]
//I want here input from Combobox the user will select.
[Category("Output")]
public OutArgument<String> CurrentDateAndTime { get; set; }
protected override void Execute(CodeActivityContext context)
{
if (Retrieve == Retrieves.CurrentDateAndTime)
{
String date = DateTime.Now.ToString();
CurrentDateAndTime.Set(context, date);
}
else
{
String date = DateTime.Now.ToString("MM/dd/yyyy");
CurrentDateAndTime.Set(context, date);
}
}
}
}
Help in getting the selected value from Combobox to the main file for execution.