I create custom bindings:
public class TextExtension : MarkupExtension
This is used to show a string by ID. How can I force the UI to update the values when there are new texts available?
I don't believe Winui supports custom markup extensions. @fabiant3 or @MikeHillberg could confirm.
Great timing, thanks @StephenLPeters . Adding @alwu-msft to comment.
@StephenLPeters: We definitely support custom markup extensions. :)
@mc0re: You'll want your markup extension to return a Binding object that it creates in code-behind. Set as the Binding object's Source and Path properties to point to the property on the object providing the updated string. That should do what you want (i.e. allow updated values to flow from the source string to the target property). If this is for a WinUI 3 app and you can wait for Preview 3 to be released, we're adding IXamlServiceProvider which will give you access to the object/property that the markup extension is being set on via the IProvideValueTarget interface and allow you to store/recall the target whenever it's time to update the displayed text; this is an alternative to constructing a Binding object.
Thanks, works like a charm.
Most helpful comment
@StephenLPeters: We definitely support custom markup extensions. :)
@mc0re: You'll want your markup extension to return a Binding object that it creates in code-behind. Set as the Binding object's Source and Path properties to point to the property on the object providing the updated string. That should do what you want (i.e. allow updated values to flow from the source string to the target property). If this is for a WinUI 3 app and you can wait for Preview 3 to be released, we're adding IXamlServiceProvider which will give you access to the object/property that the markup extension is being set on via the IProvideValueTarget interface and allow you to store/recall the target whenever it's time to update the displayed text; this is an alternative to constructing a Binding object.