So I would like to have a variable StringFormat in a binding, but I'm not sure how to do that. I don't mind if it's XAML or code behind. Here's what I currently have:
<TextBlock x:Name="TextBlockSpellSkill" Text="{Binding CurrentValue, StringFormat=Spell: {0}}" />
However, I would like to be able to change the prefix "Spell:" to, for example "Skill:" based on a variable in my model. The easiest way would be if I could do it in code behind something like this:
if (true)
{
TextBlockSpellSkill.StringFormat = "Spell: {0}";
}
else
{
TextBlockSpellSkill.StringFormat = "Skill: {0}";
}
but I couldn't find any way to just set the string format from code-behind. If there's a good way to do it in XAML I'm cool with that too!
Thanks