I want to make markup extension to simplify bidning. I have dictionary and I bind that property to a Label in the view. I have ValueConverter that takes this dictinary and I pass ConverterParameter which is a string and it finds
<Label Text="{Binding Tanslations,Converter={StaticResource TranslationWithKeyConverter}, ConverterParameter='Test'}"/>
but I have to do same thing for different labels but the key (ConverterParameter) will be different, the rest will remain same
I want a markupextension that will allow me to write this:
<Label Text="{local:MyMarkup Key=Test}"/>
this markup should generate binding to the property named "Tanslations" with valueconverter of TranslationWithKeyConverter and ConverterParameter with value of Key.
I tried to do it but it does not work:
public class WordByKey : IMarkupExtension
{
public string Key { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
return new Binding("Tanslations", BindingMode.OneWay, converter: new TranslationWithKeyConverter(), converterParameter: Key);
}
}
nothing is displayed on the label.