I need some help!
I have build a custom control and added to it a DependencyProperty
of type:
Dictionary<string,int>
and from the XAML where the control is held I do a data binding to bind to the Dictionary outside the control.
here are some code snippets: View model of the control who hold the custom control
private Dictionary<string, int> _wordsList;
public Dictionary<string, int> WordsList
{
get
{
return _wordsList;
}
set
{
_wordsList = value;
RaisePropertyChanged("WordsList");
}
}
public WordsViewModel()
{
//CalculateWordsDictionary returns a dictionary<string,int>
WordsList = CalculateWordsDictionary(texts);
}
XAML:
<local:MyControl WordsList="{Binding Path=WordsList}" />
Code behind of the custom control:
public Dictionary<string, int> WordsList
{
get { return (Dictionary<string, int>)GetValue(WordsListProperty); }
set { SetValue(WordsListProperty, value); }
}
// Using a DependencyProperty as the backing store for WordsList. This enables animation, styling, binding, etc...
public static readonly DependencyProperty WordsListProperty =
DependencyProperty.Register("WordsList", typeof(Dictionary<string, int>), typeof(MyControl), new PropertyMetadata(new Dictionary<string, int>()));
I've set a break point on the set of the DependencyProperty
and it never reaches this point.
I just can't figure out why this isn't working... or maybe there is some other way to pass the dictionary to the control?
btw I am using MVVM Light