Binding cal:View.Context to an enum on the view model

Topics: Bugs, UI Architecture
Oct 2, 2013 at 6:18 PM
I'm sure this is pretty basic but I'm having trouble getting it to work. I have the following ItemsControl and I want to use an enum value in the Window's view model as the view context for the ContentControl's view. I implemented the CreditCardItemViewType property on the Window's view model with INotifyPropertyChanged, but the CreditCardItemViewType enum value is never passed to the ViewLocator as the view context when CM attempts to locate the view. If I use a simple string value for the view context instead of binding to a property, it works just fine.

Is there something I'm missing for binding a view context to an enum on the view model?

                    <ItemsControl Margin="0,5,0,0" BorderBrush="Transparent" Background="Transparent" ItemsSource="{Binding CreditCards, UpdateSourceTrigger=PropertyChanged}">
                                <ContentControl cal:View.Model="{Binding}" cal:View.Context="{Binding CreditCardItemViewType, UpdateSourceTrigger=PropertyChanged}"/>
Oct 3, 2013 at 8:34 PM
Edited Oct 3, 2013 at 8:36 PM
<ContentControl cal:View.Model="{Binding}" cal:View.Context="{Binding CreditCardItemViewType, Mode=TwoWay}"/>

Should work just fine since one of the examples is using an Enum to view switch between master/detail

reference changes shouldn't need the trigger either.

why do you have a trigger on your ItemsSource?
Oct 3, 2013 at 11:07 PM
Which example shows the master / detail switch?
Oct 4, 2013 at 1:12 AM
HelloScreens does. Its in Silverlight but the concept doesn't change between WPF or Silverlight.
Oct 4, 2013 at 9:24 PM
Thanks so I was able to implement it for a ContentControl that resides in a grid within my control, however, I'm still having trouble getting this to work with the ContentControl in the DataTemplate in the ItemsControl shown above. Would there be any differences in the code or approach when applying the view context to a ContentControl within an ItemsControl?