I have the following situation:
I have a few ViewModel objects, some of which implement an interface ISomeInterface
, some don't. The interfaces exposes a property called SomeEnumeration
(IEnumerable<T>
).
For example:
public sealed class ViewModelA : ViewModelBase, ISomeInterface
{
// ...
IEnumerable<Foo> ISomeInterface.SomeEnumeration
{
get { ...; }
}
}
public sealed class ViewModelB : ViewModelBase
{
// ...
}
My XAML, so far, has been designed in a way that both of the ViewModels happen to have the properties I am binding against (i.e. PropertyA
, PropertyB
, etc.). I haven't ran into the situation yet where a property I am binding against does not exist on the ViewModels that I am setting as the DataContext
. But, now I will... and it will be against a property that is explicitly implemented (I'm not sure if that makes any difference in the WPF Binding Engine).
Basically, my xaml will look like the following:
<StackPanel
Visiblity="{Binding Path=SomeEnumeration, Converter={StaticResource AnyConverter}">
...
</StackPanel>
I'm not sure if this will even work because:
- Not every
DataContext
will contain the property (in case it doesn't, it should be hidden) ... What should I do in this case? - For the
DataContext
s that do contain the property, it is explicitly implemented ... do you have to cast first or something?