gpt4 book ai didi

c# - Workflow Foundation - 在自定义设计器中分配 InArgument

转载 作者:太空狗 更新时间:2023-10-29 23:16:06 24 4
gpt4 key购买 nike

我在使用 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 中键入内容时,出现错误:左值表达式无效,但如果我在属性网格中键入值,TextBox 会更新。

有没有人见过这个?

谢谢。

最佳答案

从您的 XAML 中删除 UseLocationExpression 属性或将其设置为 False。您的其余代码似乎是正确的。

查看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. When you are binding the ExpressionTextBox to an Out argument, you would set this property to True.

它仅在您要绑定(bind) OutArgument 时使用。

关于c# - Workflow Foundation - 在自定义设计器中分配 InArgument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14653027/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com