我在使用Workflow Foundation中的自定义活动和设计器时遇到问题。为了回答这个问题,我创建了一个非常简单的活动,如下所示:
[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);
}
}设计器如下所示:
<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就会更新。
有没有人见过这个?
谢谢。
发布于 2013-02-02 03:57:50
从XAML中移除UseLocationExpression属性或将其设置为False。您的其余代码看起来是正确的。
检查MSDN上的属性备注
位置表达式(或L值表达式)是一种计算结果为标识符的表达式,可以放在赋值语句的左侧。将ExpressionTextBox绑定到Out参数时,应将此属性设置为True。
它只在你想要绑定一个OutArgument的时候使用。
https://stackoverflow.com/questions/14653027
复制相似问题