Converting string to UIElement

357 Views Asked by At

Is there a way to convert string to UIElement? I'm trying to add text to my graph's legend using an Interactive data display. The legend needs to not correlate with a plotted graph so I'm making my own like so:

LegendItemsPanel legendItemsPanel = new LegendItemsPanel() 
{
            
};
Legend legend = new Legend() 
{
   Content = legendItemsPanel
};
Rectangle rectUP = new Rectangle()
{
   Width = 10,
   Height = 10,
   Fill = new SolidColorBrush(Colors.Red),
   Stroke = new SolidColorBrush (Colors.Red),
};
UIElement element() 
{
   UIElement output = new UIElement();
   output.Equals(rectUP + " Upstream band");
   return output;
}
legendItemsPanel.Children.Add(element());

I've tried a lot of possibilities but every time I get the same error "Cannot convert from 'string' to 'Windows.System.UIElement'". Could someone please help me out with this one? Thank you

0

There are 0 best solutions below