I have EntitiesUserControl
responsible for EntitiesCount
dependency property:
public static readonly DependencyProperty EntitiesC
It's a „bit” hacky, but you can create a Binding
-derived class and use that instead of Binding
:
[MarkupExtensionReturnType(typeof(OneWayToSourceBinding))]
public class OneWayToSourceBinding : Binding
{
public OneWayToSourceBinding()
{
Mode = BindingMode.OneWayToSource;
}
public OneWayToSourceBinding(string path) : base(path)
{
Mode = BindingMode.OneWayToSource;
}
public new BindingMode Mode
{
get { return BindingMode.OneWayToSource; }
set
{
if (value == BindingMode.OneWayToSource)
{
base.Mode = value;
}
}
}
}
In XAML:
<controls:EntitiesUserControl EntitiesCount="{local:OneWayToSourceBinding CountOfEntities}" />
The namespace mapping local
might be something else for you.
This OneWayToSourceBinding
sets the Mode
to OneWayToSource
and prevents setting it to anything else.