I created UserControl with viewmodel. It has DependencyProperty which only works if the value is passed directly. If the value is passed through the binding, it no longer works.
When you set the DataContext
explicitly in the UserControl
like this:
...you can no longer bind to SomeView
's DataContext
in the consuming view like this:
...because SomeViewModel
doesn't have any IsConnected
property.
You should avoid setting the DataContext
explicitly and let the UserControl
inherit its DataContext
from its parent element. You can still bind to the dependency property of the UserControl
itself using a RelativeSource
or an ElementName
:
Besides, SomeViewModel
seems superfluous in your example since the UserControl
already has an Active
property.