How about dropping all the Background
stuff and just write a standard dependency property wrapper like this:
public double ImageOffset
{
get { return (double)GetValue(ImageOffsetProperty); }
set { SetValue(ImageOffsetProperty, value); }
}
When the property is set from a background thread, put the assignment in a Dispatcher.Invoke
or Dispatcher.BeginInvoke
call.
Replace
obj.ImageOffset = someOffset;
by
Dispatcher.Invoke(() => obj.ImageOffset = someOffset);
or
Application.Current.Dispatcher.Invoke(() => obj.ImageOffset = someOffset);
if you don't have direct access to the Dispatcher
property of some UI element.