I want to grab the default Style
for a TextBlock
in code behind without ever having adding a custom default TextBlock
Style
to resources in XAML
.
I've got a method like this:
public TextBlock DrawTextBlockAtPoint(string text, Style style)
{
//...
}
that I want to provide an override that just uses the regular TextBlock
Style
:
public TextBlock DrawTextBlockAtPoint(string text)
{
var style = GetDefaultStyleForProperty(TextBlock.StyleProperty);
DrawTextBlockAtPoint(text, style)
}
Is there anyway to do this?
typeof
and using the container where the style was declared (my case was aStackPanel
, previously I usedFindResource
on theWindow
and it wasn't working). – Money