首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >工作流基础-在自定义设计器中分配InArgument

工作流基础-在自定义设计器中分配InArgument
EN

Stack Overflow用户
提问于 2013-02-02 02:47:17
回答 1查看 3.1K关注 0票数 5

我在使用Workflow Foundation中的自定义活动和设计器时遇到问题。为了回答这个问题,我创建了一个非常简单的活动,如下所示:

代码语言:javascript
复制
[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);
    }
}

设计器如下所示:

代码语言:javascript
复制
<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>

当我在TextBox中输入一些东西时,我得到一个错误:无效的l-值表达式,但是如果我在属性网格中输入值,TextBox就会更新。

有没有人见过这个?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-02 03:57:50

从XAML中移除UseLocationExpression属性或将其设置为False。您的其余代码看起来是正确的。

检查MSDN上的属性备注

位置表达式(或L值表达式)是一种计算结果为标识符的表达式,可以放在赋值语句的左侧。将ExpressionTextBox绑定到Out参数时,应将此属性设置为True。

它只在你想要绑定一个OutArgument的时候使用。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14653027

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档