protected void UpdateValue()
{
var value = GetValue();
if (_targetObject != null)
{
var targetPropertyAsDependencyProperty = _targetProperty as DependencyProperty;
if (targetPropertyAsDependencyProperty != null)
{
var obj = _targetObject as DependencyObject;
if (obj == null)
{
return;
}
Action updateAction = () => obj.SetValue(targetPropertyAsDependencyProperty, value);
#if NETFX_CORE
if (obj.Dispatcher.HasThreadAccess)
{
UpdateValue();
}
else
{
#pragma warning disable 4014
obj.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => updateAction());
#pragma warning restore 4014
}
#else
if (obj.CheckAccess())
{
updateAction();
}
else
{
obj.Dispatcher.Invoke(updateAction);
}
#endif
}
else
{
var prop = _targetProperty as PropertyInfo;
if (prop != null)
{
prop.SetValue(_targetObject, value, null);
}
}
}
}