CsDebugScript.UI.InteractiveResultVisualizer.CreateTextWithIcon C# (CSharp) Method

CreateTextWithIcon() private method

private CreateTextWithIcon ( string text, ImageSource icon, object tooltip = null ) : UIElement
text string
icon ImageSource
tooltip object
return UIElement
        private UIElement CreateTextWithIcon(string text, ImageSource icon, object tooltip = null)
        {
            return dispatcher.Invoke(() =>
            {
                StackPanel stackPanel = new StackPanel();
                stackPanel.Orientation = Orientation.Horizontal;
                Grid.SetColumn(stackPanel, NameColumnIndex);
                TextBlock textBlock = new TextBlock();
                textBlock.Text = text;
                Image image = new Image();
                image.Width = image.Height = 16;
                image.Source = icon;
                image.ToolTip = tooltip;
                stackPanel.Children.Add(image);
                stackPanel.Children.Add(textBlock);
                return stackPanel;
            });
        }

Usage Example

 protected object GetValue(Func <object> getValueFunction)
 {
     try
     {
         return(getValueFunction());
     }
     catch (Exception ex)
     {
         return(interactiveResultVisualizer.CreateTextWithIcon("Exception", ExceptionImage, ex.ToString()));
     }
 }