Workflow Foundation - Assign InArgument in Custom Designer

I'm having trouble using custom actions and designers in the Workflow Foundation. For the sake of the question, I created a very simple action, 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 constructor is as follows:

<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 enter something into a TextBox, I get an error: invalid l-value expression, but if I type the value in the property grid, the TextBox will be updated.

Has anyone seen this?

Thank.

+5
source share
1 answer

Remove the UseLocationExpression property from your XAML or translate it to False. The rest of your code seems to be correct.

Note the MSDN property notes :

( L-) . ExpressionTextBox Out, .

, OutArgument.

+4

All Articles