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, December 9, 2013 12:37 PM


  • Hi,

    You cand debug your code to check if the fileName variable is null. And please try the code below

    private void Button_Click( object sender, RoutedEventArgs e ) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "All Files (*.*)|*.*"; Nullable<bool> result = dlg.ShowDialog(); if( result== true ) { //please check if property is null.

    ModelProperty property = this.ModelItem.Properties[ "YourTextBoxID" ]; property.SetValue( dlg.FileName ); } }

    For more information, you can refer here

    #Deep Dive into the WF4 Designer Data Model: ModelItem and ModelProperty



    Hope it can help you.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by Pengzhen Song Thursday, December 19, 2013 12:23 PM
    Tuesday, December 10, 2013 2:18 AM