private TextBlock AddContentToGrid(FrameworkElement parent, string content, ref int gridRow, int gridColumn, string style, string tooltip = null)
{
var panel = parent as Panel;
var decorator = parent as Decorator;
var textBlock = new TextBlock
{
Style = (Style)FindResource(style),
Text = content,
ToolTip = tooltip ?? content
};
Grid.SetColumn(textBlock, gridColumn);
Grid.SetRow(textBlock, gridRow++);
if (panel != null)
{
panel.Children.Add(textBlock);
}
else if (decorator != null)
{
decorator.Child = textBlock;
}
else
{
throw new ArgumentException(nameof(parent) + " is not a Panel nor a Decorator", nameof(parent));
}
return textBlock;
}