用于SharePointOnlineCredentials的WWF自定义活动绑定

时间:2018-11-06 23:12:40

标签: c# xaml csom custom-activity

我创建了一组WWF自定义活动,以通过CSOM与SharePoint进行交互。我创建了以下活动,但是,我在绑定XAML设计器中的参数时遇到了麻烦,我已经在XAML文件中导入了Microsoft.SharePoint.Client名称空间,但是当出现以下错误(The name "SharePointOnlineCredentials" does not exist in the namespace "clr-namespace:Microsoft.SharePoint.Client")时我尝试将ExpressionType绑定到sp:SharePointOnlineCredentials

有人可以建议我如何将ExpressionTextBox ExpressionType绑定为SharePointOnlineCredentials吗?

注意:我意识到某些代码丢失了,这是有意的!

活动分类

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设计

<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>

1 个答案:

答案 0 :(得分:0)

此问题是由于缺少程序集引用引起的。

如果您查看MSDN上的类详细信息,则命名空间为Microsoft.SharePoint.Client,而集合为Microsoft.SharePoint.Client.Runtime

通过将xmlns:sp="clr-namespace:Microsoft.SharePoint.Client"更改为xmlns:sp="clr-namespace:Microsoft.SharePoint.Client;assembly=Microsoft.SharePoint.Client.Runtime",问题得以解决。