We have a dynamic languaging system that doesn't use conventional resource files; fetching resources from a database, via a language manager library instead. Based on a legacy (VB6) solution, it languages controls according to the resource name in the control's tag property. After the page has initialised we fire off a method that takes LayoutRoot and recurses it's children applying strings looked up from the tag where the control has one. This proves to be unwieldy, the recursive routine has turned into a monster to cater for the subtleties of different controls and I want to change to using data binding to apply the strings instead.
I realise I could declare properties to bind to for each control but this will involve a lot of code and I'm hoping there is a better way. Is there some way to bind to a method, passing a parameter. I envisage a method something like this.
public string GetResource(string resourceName)
{
string resource = <fetch resource from language manager>;
if (String.IsNullOrEmpty(resource))
{
return resourceName;
}
else
{
return resource;
}
}
We already have a static method in our application for this retrieval, which has the following signature.
public static Resource(string resourceName, string defaultValue)
To be able to use that directly would be great.