[英]Workflow Foundation - Assign InArgument in Custom Designer
我在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。
有人看過嗎?
謝謝。
從XAML中刪除UseLocationExpression屬性,或將其設置為False 。 您的其余代碼似乎正確。
查看MSDN上的屬性說明:
位置表達式(或L值表達式)是一種表達式類型,其值為標識符,可以放置在賦值語句的左側。 將ExpressionTextBox綁定到Out參數時,可以將此屬性設置為True。
僅在要綁定OutArgument時使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.