Hi All, I am trying to handle dynamic language changing in my app.
Probably relatively simple but I am trying to pass the pages binding context as a param to a converter to give access the AppResources:
The property I want to get access to in the converter is AppResources
in the page model:
public LocalizedResources AppResources
{
get;
private set;
}
I access resources with a key like this:
public string this[string key]
{
get
{
return _resourceManager.GetString(key, _currentCultureInfo);
}
}
So in my XAML page with a label I do this and it works fine:
Text="{Binding AppResources[LanguageLabel]}"
Im just trying to provide access to the converter with the bindingcontext like this but not working:
<pages:BaseContentPage
x:Class="MyApp.Pages.ThePage"
x:Name="Foo"
...>
Text="{Binding HouseKeepingHistoryStatus, Converter={StaticResource HousekeepHistoryStatusToProgressDescriptionConverter}, ConverterParameter={x:Static Foo}}"
not working either:
<Label
FontFamily="{StaticResource RegularFont}"
FontSize="{StaticResource SubHeader}"
Text="{Binding HouseKeepingHistoryStatus, Converter={StaticResource HousekeepHistoryStatusToProgressDescriptionConverter},ConverterParameter={Binding .}}"
TextColor="White"
VerticalOptions="Center" />
I bassically just want to get access to LocalizedResources file i.e. AppResources to my converter so maybe I can do it directly rather then the containing page model.
Alternatively when I try to define a property on the Converter like this:
public LocalizedResources LocalizedResources { get; set; }
and in xaml I do below I but get mismatch error i.e. No property, bindable property, or event found for 'LocalizedResources', or mismatching type between value and property
.:
<pages:BaseContentPage.Resources>
<ResourceDictionary>
<converter:HousekeepHistoryStatusToProgressDescriptionConverter x:Key="HousekeepHistoryStatusToProgressDescriptionConverter" LocalizedResources="{Binding AppResources}" />
</ResourceDictionary>
</pages:BaseContentPage.Resources>
Is there a straight forward way to handle this?