Binding to indexers
Posted: 10 Jun 2014, 10:38
In WPF, you can bind to 'property indexers'.
Example of a viewmodel that contains a Dictionary:
In the view I can now bind directly to items in this dictionary:
Is there any way I can do this in NoesisGUI as well? Binding to indexers doesn't seem to work, so at this moment I have to create a new property for each item in the dictionary. That is very cumbersome.
I want to use this to make an app that will support many languages. So instead of coding all the text in the XAML, I want to store the text in a Dictionary and I'm looking for a nice way to access these Dictionaries from XAML.
Example of a viewmodel that contains a Dictionary:
Code: Select all
public class ViewModel
{
public ViewModel()
{
Resources = new Dictionary<string, string>();
Resources["ButtonResource"] = "PLAY";
}
public Dictionary<string, string> Resources { get; private set; }
}
Code: Select all
<Button Content="{Binding Resources[ButtonResource]}"/>
I want to use this to make an app that will support many languages. So instead of coding all the text in the XAML, I want to store the text in a Dictionary and I'm looking for a nice way to access these Dictionaries from XAML.