locked
Activity Designer with OpenFileDialog RRS feed

  • Question

  • I have a custom activity with an InArgument<string> FileName. I want to write a designer for it, where I can choose a file. I think what I need is a ExpressionTextBox and a button. What code is needed in the eventhandler of the button? How can I set the FileName of the activity with the result of the OpenFileDialog?

     

    Monday, November 29, 2010 12:52 PM

Answers

  • can you try to put this converter to the binding if you are using the expression textbox

    <sadv:ExpressionTextBox Expression="{Binding Path=ModelItem.Program Mode=TwoWay, Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In}" OwnerActivity="{Binding Path=ModelItem}"/>

    • Marked as answer by Andrew_Zhu Monday, December 6, 2010 8:30 AM
    Tuesday, November 30, 2010 9:53 AM

All replies

  • is this what you are looking for?

    I have pasted the sample code there

    http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/54badb5f-9f3a-4dcb-994d-cd033baeb25f

    Monday, November 29, 2010 6:39 PM
  • I don't think that this is the same problem. I do not want a special editor, but a custom activity designer. Now I found a solution if I change the InArgument<string> to a plain CLR property of type string. On the surface I have a textbox and a button. The textbox is bound to the modelItem.Program. In the button click eventhandler I can set the value of this property. It works fine.

        <StackPanel >
            <TextBlock Text="Program:" Margin="6"/>
            <DockPanel>
                <Button DockPanel.Dock="Right" Padding="6,0,6,0" Click="Button_Click" >...</Button>
                <TextBox
                    Name="txtProgram"   
                    Text="{Binding Path=ModelItem.Program, Mode=TwoWay }" />
            </DockPanel>
        </StackPanel>

           private void Button_Click( object sender, RoutedEventArgs e )
            {
                if( _openFileDialog.ShowDialog() == true )
                {
                    ModelProperty property = this.ModelItem.Properties[ "Program" ];
                    property.SetValue( _openFileDialog.FileName );
                }
            }

    What do I have to change, if I want to use an InArgument<string> in the activity? Instead of the <TextBox> I need an <ExpressionTextBox>. But what code is needed in the click eventhandler? How can I convert the string _openFileDialog.FileName to an InArgument<string>?

    By the way: The above solution does not work, if I change the eventhandler to txtProgram.Text=_openFileDialog.FileName instead of property.SetValue... Why isn't the binding working correct?

    Tuesday, November 30, 2010 8:50 AM
  • can you try to put this converter to the binding if you are using the expression textbox

    <sadv:ExpressionTextBox Expression="{Binding Path=ModelItem.Program Mode=TwoWay, Converter={StaticResource ArgumentToExpressionConverter}, ConverterParameter=In}" OwnerActivity="{Binding Path=ModelItem}"/>

    • Marked as answer by Andrew_Zhu Monday, December 6, 2010 8:30 AM
    Tuesday, November 30, 2010 9:53 AM
  • Thanks for your help. It works!
    Monday, December 6, 2010 9:26 AM
  • Hi Ofri66,

    my requirement is also same of OpenFileDialog please put a working code in the form, i try above code but it was giving the null point reference.

    Monday, December 9, 2013 12:34 PM