I have a solution with a couple of projects. In one project, is my model that has an enum called ModelEnum.
Then in my WPF project I have a ViewModel which has a Dictionary.
And in my ViewModel I have my ValuesDictionary setup as:
private Dictionary<ModelEnum, string> _valuesDictionary = new Dictionary<ModelEnum, string>();
public Dictionary<ModelEnum, string> ValuesDictionary
{
get { return _valuesDictionary; }
set { _valuesDictionary = value; OnPropertyChanged(_valuesDictionary); }
}
In my XAML I have:
xmlns:model="clr-namespace:Model.Data;assembly=Model"
...
<TextBox Text="{Binding Path=ValuesDictionary[(model:ModelEnum)ModelEnum.Enum1].Value}" HorizontalAlignment="Left" Height="29" Margin="90,82,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="50"/>
The following XAML snippet:
(model:ModelEnum)ModelEnum.Enum1
is giving me the error "Parameter type mismatch." I'm confused because I thought I was casting this to the Enum type that it was expecting. I referenced this SO question to try it with no luck.