private Action OnStartQuery(Type type, IEnumerable result) { Controls.SequenceDiagram diagram = null; if (type == typeof(SequenceDiagram)) { diagram = new Controls.SequenceDiagram(); this.ResultPanel.RowDefinitions.Add(new RowDefinition()); diagram.SetValue(Grid.RowProperty, this.ResultPanel.RowDefinitions.Count - 1); this.ResultPanel.Children.Add(diagram); } else { this.AddResultGrid(result); } bool hasX, hasY; Action completion = () => { if (type == typeof(SequenceDiagram)) { foreach (var item in result) { RenderDiagram(item as SequenceDiagram, diagram); break; } } else { if (QueryWindowHelpers.CanShowChart(type, out hasX, out hasY)) { var chart = this.AddChart(); QueryWindowHelpers.PopulateChart(chart, hasX, type, result); } } }; return(completion); }