R. D. Brown

I'm hosting the workflow designer in my own application. I'm trying to display the validation error icons on an activity when it is not configured properly. I've attached validators to my custom activities and by using the code:

WorkflowTheme.CurrentTheme.ReadOnly = false;

WorkflowTheme.CurrentTheme.AmbientTheme.ShowConfigErrors = true;

WorkflowTheme.CurrentTheme.ReadOnly = true;

I can make the icons appear when the validate methods fails. However, the dropdown on the icons is always empty. I'm filling in error messages in my activity's validator. Those error messages appear on the dropdown when I'm viewing the workflow in Visual Studio, but not in my own application. Does anyone know how to make the error messages appear in a custom application

Thanks.



Re: Windows Workflow Foundation Displaying Error Icons when hosting the Designer

Tim Wright

I'm not sure it's much help, but this doesn't work in the HOL exercise either.



Re: Windows Workflow Foundation Displaying Error Icons when hosting the Designer

_vihang

You will need to write your own MenuCommandService, override ShowContextMenu and then create and display the context menu. For a sample implementation of MenuCommandService, download the sample at http://download.microsoft.com/download/C/3/2/C325E3B1-9B85-407C-8C4B-422A5CF04126/WorkflowDesignerControl.EXE

 

Open the WorkflowMenuCommandService.cs and in the ShowContextMenu method add the following code:

if (menuID == WorkflowMenuCommands.DesignerActionsMenu)
  {
  ContextMenu contextMenu1 = new ContextMenu();
  IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;
  ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

  if (selectionService != null)
  {
    ValidationErrorCollection validationErrors = new ValidationErrorCollection();
    Activity act = selectionService.PrimarySelection as Activity;
    ValidationManager validationManager = new ValidationManager(host.RootComponent.Site);
   
    foreach (Validator validator in validationManager.GetValidators(act.GetType()))
      validationErrors.AddRange(validator.Validate(validationManager, act));
    for (int i = 0; i < validationErrors.Count; i++)
    {
      ValidationError error = validationErrorsIdea as ValidationError;
      MenuItem menuItem = new MenuItem(error.ErrorText, new EventHandler(OnMenuClicked));
      contextMenu1.MenuItems.Add(menuItem);
    }
  }
  WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView;
  if (workflowView != null)
    contextMenu1.Show(workflowView, workflowView.PointToClient(new Point(x, y)));
  }

This will display the error in the re-hosted designer.






Re: Windows Workflow Foundation Displaying Error Icons when hosting the Designer

Webbert

I posted a similar message: http://forums.microsoft.com/MSDN/showpost.aspx postid=409627&siteid=1

I am trying to get the Error Icon to display when the item is dropped on the workflow. Your message seems to indicate that you got this to work just by using the WorkflowThemem.CurrentTheme class listed above. Is this all the code that is required

From my investigation, for my problem, it seems that the validator is not being fired when the object is dropped on the Workflow. The validator is only being fired when I compile. Is there an event that I need to wire

Thanks,
Dave




Re: Windows Workflow Foundation Displaying Error Icons when hosting the Designer

thefronciak

_vihang: thanks for your idea, I added it to my re-hosted designer and it works, but I have the other problem with it: when menu is shown, wherever I click, the menu shows again in the same position. Only clicking on one of its (not working anyway) commands makes menu hide. Can you tell me what to do to deal with this problem

Thanks.


//edit: doubleclick closes menu too.




Re: Windows Workflow Foundation Displaying Error Icons when hosting the Designer

Chris Richner

I'm facing the same issue, could you please share the answer with us,)

Thanks