Search code examples
c#xamlcsomcustom-activity

WWF Custom Activity binding for SharePointOnlineCredentials


I have created a set of WWF custom activities to interact with SharePoint via the CSOM. I have created the below Activity, however, I am struggling to bind the Arguments in the XAML Designer, I have imported the Microsoft.SharePoint.Client namespace in the XAML file but I am getting the following error (The name "SharePointOnlineCredentials" does not exist in the namespace "clr-namespace:Microsoft.SharePoint.Client") when I try binding the ExpressionType to sp:SharePointOnlineCredentials.

Can anyone advise on how I bind the ExpressionTextBox ExpressionType to be SharePointOnlineCredentials?

Note: I realise that some of the code is missing, this is deliberate!

Activity Class

using Microsoft.SharePoint.Client;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

namespace Custom_Activities.SharePoint
{
    public sealed class List_To_DataTable : CodeActivity
    {
        [Category("Input")]
        [DisplayName("SharePoint Credentials")]
        public InArgument<SharePointOnlineCredentials> SharePoint_Credentials { get; }

        protected override void Execute(CodeActivityContext context)
        {
            DataTable table = new DataTable();
            //Gets content

            Dt.Set(context,table);

        }
    }
}

XAML Design

<sap:ActivityDesigner 
    x:Class="CS_Activities.SharePoint.Design.List_To_DataTable_Designer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    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:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:sp="clr-namespace:Microsoft.SharePoint.Client">
    <sap:ActivityDesigner.Resources>
        <ResourceDictionary x:Uid="ResourceDictionary_1">
            <sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
            <sapc:ModelToObjectValueConverter x:Key="ModelToObjectValueConverter" /> 

    <DataTemplate x:Key="Collapsed">
        <TextBlock VerticalAlignment = "Center" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="0" Margin="5" Text="List Name" />
        <sapv:ExpressionTextBox HintText = "Enter you Sharepoint Credentials" Expression="{Binding Path=ModelItem.SharePoint_Credentials, Mode=TwoWay, Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In }" ExpressionType="sp:SharePointOnlineCredentials" Grid.Row="0" Grid.Column="1" OwnerActivity="{Binding Path=ModelItem}" Width="300" Margin="0,5" MaxLines="1" />
    </DataTemplate>

Solution

  • The issue was caused due to the assembly reference missing.

    If you look at the class details on MSDN the Namespace is Microsoft.SharePoint.Client and the assemvly is Microsoft.SharePoint.Client.Runtime

    By changing xmlns:sp="clr-namespace:Microsoft.SharePoint.Client" to xmlns:sp="clr-namespace:Microsoft.SharePoint.Client;assembly=Microsoft.SharePoint.Client.Runtime" the issue is resolved.