none
Windows Workflow Foundation 4.0 ActivityDesigner

    Question

  • Hello. At me is custom activity and connected with it activityDesigner. By pressing the button which is located on activityDesigner show WPF forms in which the user sets value. At closing of this form value should be displayed in ExpressionTextBox. Prompt, whether is possible so to connect to (display)?

    <sap:ActivityDesigner x:Class="ActivityLibrary.SendMailDesigner"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:s="clr-namespace:System;assembly=mscorlib"

    xmlns:net="clr-namespace:System.Net.Mail;assembly=System"

    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"

    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"

    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" >

    <sap:ActivityDesigner.Resources>

    <sapc:ArgumentToExpressionConverter x:Uid="sadv:ArgumentToExpressionConverter_1" x:Key="argumentToExpressionConverter" />

    </sap:ActivityDesigner.Resources>

    <Expander>

    <Grid Height="108" HorizontalAlignment="Left" Name="grid1" VerticalAlignment="Top" Width="278">

    <Label Content="Body" HorizontalAlignment="Left" Name="labelBody" VerticalAlignment="Top" />

    <sapv:ExpressionTextBox Grid.Column="1" HorizontalAlignment="Left" Name="ctrlBody" VerticalAlignment="Top"

    AutomationProperties.AutomationId="To"

    Expression="{Binding Path=ModelItem.Body, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=In}"

    ExpressionType="{x:Type TypeName=s:String}"

    OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}"

    /> - my ActivityDesigner

    public partial class SendMailDesigner

    {

    private void button1_Click(object sender, RoutedEventArgs e)

    {

    MainWindow f = new MainWindow();

    if (f.ShowDialog() == true)

    {

    object o = f.Test;// f.Test - string

    this.ctrlBody.Expression - how set value ???

    }

    }
    Thursday, January 21, 2010 2:35 PM

All replies

  • Let's say that your ETB is bound to "Foo" [in your code above, you bind to Body, I'm not sure that's what you want to bind it to, unless Body is the expression, you likely want to bind it to an InArgument<String> ]

    Anyway, in the code beside you need to do

    this.ModelItem.Properties["Foo"].SetValue(your value here)

    Now, if an ETB is bound to Foo, you most likely want to wrap whatever is returned from the dialog in a VBValue expression

    which would look like

    this.ModelItem.Properties["Foo"].SetValue(new VisualBasicValue { ExpressionText= "your constructed VB expression string here" } );


    Basically, you don't want to try to set the Expression directly on the UI Element, write it to the underlying data object that the ETB is bound to.

    matt


    Program Manager -- wf designer -- http://blogs.msdn.com/mwinkle
    Thursday, January 21, 2010 5:49 PM
  • Thanks for the help. At me it has turned out..

      Window1 f = new Window1();
       if (f.ShowDialog() == true)
       {
        
        Argument ArgDoc = Argument.Create(typeof(Guid), ArgumentDirection.In);
        ArgDoc.Expression = new VisualBasicValue<Guid>
        {
         ExpressionText = f.id.ToString()
        };
        
        this.ModelItem.Properties["MyG"].SetValue(ArgDoc);
       }

    Wednesday, January 27, 2010 12:12 PM