Collection of BaseBinding
Posted: 27 Nov 2020, 13:31
Hi guys,
We have a "CustomTextBlock" which derives from a regular "TextBlock" and allows us to control the way the text block works. We want to be able to replace some of the text within based on some string formatting rules:
Right now the "{SomeVariable}" sub string is just replaced in code, something like:
This will then internally rebuild the string and the text will then look like
Some Variable: SomeValue
I want full binding support for this in the editor. Ideally I want something like the following:
Does this sound reasonable? I've looked online and I've not seen a nice way to do this. I've looked into how BaseTrigger does it and it seems fairly complicated by having to create a binding listener and then register the CustomTextBlockVariables as a tree node and then attach / detach them at runtime. I'm willing to look more into this but I was just wondering if there was a simpler way to try to do what I'm doing. Perhaps this would work better as a converter instead with a multi data binding for the variables?
Cheers,
-Steven
We have a "CustomTextBlock" which derives from a regular "TextBlock" and allows us to control the way the text block works. We want to be able to replace some of the text within based on some string formatting rules:
Code: Select all
<CustomTextBlock Text="Some Variable: {SomeVariable}" />Code: Select all
CustomTextBlock *pTB = GetTextBlock();
pTB->AddVariable("SomeVariable", "SomeValue");
Some Variable: SomeValue
I want full binding support for this in the editor. Ideally I want something like the following:
Code: Select all
<CustomTextBlock Text="Some Variable: {SomeVariable}" >
<CustomTextBlock.Variables>
<CustomTextBlockVariable Variable="SomeVariable" Binding="{Binding SomeValueFromDataContext}" />
</CustomTextBlock.Variables>
</CustomTextBlock>Cheers,
-Steven