I’ve implemented a class that takes care of loading objects asynchronously and takes care of changing the cursor accordingly, namely in the UpdateCursor method:
static Cursor cursor;
public AsyncLoader(Func<CbT> request, Callback callback, Cursor cursor)
{
this.request = request;
this.callback = callback;
AsyncLoader<CbT>.cursor = cursor;
LatestRequestId = Guid.NewGuid();
UpdateCursor();
...
}
void UpdateCursor()
{
if (LatestRequestId == Guid.Empty)
{
cursor = Cursors.Arrow;
}
else
{
cursor = Cursors.AppStarting;
}
}
In the class where I’m going to use this class I have the Cursor property which implements INotifyProperty and it’s bound to the window’s cursor:
private Cursor _CurrentCursor;
public Cursor CurrentCursor
{
get { return _CurrentCursor; }
set
{
if (value != _CurrentCursor)
{
_CurrentCursor = value;
OnPropertyChanged("CurrentCursor");
}
}
}
In the View:
Cursor="{Binding CurrentCursor}"
The question is, how can I pass the CurrentCursor to the AsyncLoader, so that when the UpdateCursor runs, the changes will be reflected back to the CurrentCursor and fire the PopertyChange event?
One of the solution would be to create an interface
Pass instance of type ICursorHolder to the AsyncLoader and to implement this interface in your class with Cursor property
and your class
Upd1
Updated sample code
Upd2