简体   繁体   English

Workflow Foundation-在Custom Designer中分配InArgument

[英]Workflow Foundation - Assign InArgument in Custom Designer

I'm having a problem using custom activities and designers in Workflow Foundation. 我在Workflow Foundation中使用自定义活动和设计器时遇到问题。 For the sake of the question, I've created a very simple activity, as shown below: 出于问题的考虑,我创建了一个非常简单的活动,如下所示:

[Designer(typeof(TesteDesigner))]
public sealed class Teste : CodeActivity
{
    // Define an activity input argument of type string
    [RequiredArgument]
    public InArgument<string> Text { get; set; }

    // If your activity returns a value, derive from CodeActivity<TResult>
    // and return the value from the Execute method.
    protected override void Execute(CodeActivityContext context)
    {
        // Obtain the runtime value of the Text input argument
        string text = context.GetValue(this.Text);
    }
}

And the designer is the following: 设计者如下:

<sap:ActivityDesigner x:Class="ActivityDesignerLibrary1.TesteDesigner"
                      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:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
                      xmlns:System="clr-namespace:System;assembly=mscorlib"
                      xmlns:Converters="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation">
    <sap:ActivityDesigner.Resources>
        <Converters:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
    </sap:ActivityDesigner.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <TextBlock Text="Valor: "
                   VerticalAlignment="Center" />
        <sapv:ExpressionTextBox HintText="Valor"
                                Expression="{Binding Path=ModelItem.Text, Mode=TwoWay, Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In}"
                                ExpressionType="{x:Type System:String}"
                                OwnerActivity="{Binding Path=ModelItem}"
                                UseLocationExpression="True"
                                Grid.Column="1"
                                Margin="3,0,0,0" />
    </Grid>
</sap:ActivityDesigner>

When I type something in the TextBox, I get an error: invalid l-value expression, but if I type the value on the property grid, the TextBox is updated. 当我在TextBox中键入内容时,出现错误:无效的l值表达式,但是如果我在属性网格中键入值,则将更新TextBox。

Has anyone ever seen this? 有人看过吗?

Thanks. 谢谢。

Remove UseLocationExpression property from your XAML or turn it to False . 从XAML中删除UseLocationExpression属性,或将其设置为False The rest of your code seems correct. 您的其余代码似乎正确。

Check the property remarks on MSDN : 查看MSDN上的属性说明:

A location expression (or L-value expression) is a type of expression that evaluates to an identifier and can be placed on the left hand side of an assignment statement. 位置表达式(或L值表达式)是一种表达式类型,其值为标识符,可以放置在赋值语句的左侧。 When you are binding the ExpressionTextBox to an Out argument, you would set this property to True. 将ExpressionTextBox绑定到Out参数时,可以将此属性设置为True。

It's only to be used when you want to bind an OutArgument. 仅在要绑定OutArgument时使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 客户端应用程序中的Windows工作流基础设计器 - Windows workflow foundation designer in client application 在Workflow Foundation 4.0中,如何在声明了Activity的Execute方法之外读取InArgument的值? - How can I, in Workflow Foundation 4.0, read the value of an InArgument outside of the Execute method of the Activity in which it has been declared? 工作流中的InArgument到OutArgument转换导致错误 - The InArgument to OutArgument Conversion in Workflow causing error 以编程方式启动工作流时设置InArgument - Set InArgument when launching a workflow programmatically Workflow Foundation中自定义活动的可选参数 - Optional Argument for Custom Activities in Workflow Foundation 将图像添加到Windows工作流自定义活动设计器 - Add an image to a windows workflow custom activity designer 退出自定义C#CRM工作流回到设计器工作流 - Exit custom C# CRM Workflow back into designer workflow Windows Workflow Foundation-在工作流中的不同活动之间传递自定义变量 - windows Workflow foundation - passing custom variable between different activity in a workflow 我可以在Workflow Designer中使用书签/自定义活动吗? - Can I use bookmarks/custom activity in Workflow designer? Workflow Foundation 4-显示工作流程进度 - Workflow Foundation 4 - Showing Workflow Progress
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM