So you are in WPF or Silverlight, and you want to invoke a method on an abitrary object (either the data provider or your business object) in response to a Click event?
Handle the event in code-behind, get the data provider from the Resources dictionary and invoke its Refresh() method. Several of the WPF/Silverlight sample apps get the data provider from Resources and interact with it in code-behind - just check through the sample apps.
Or search the web for the MVVM pattern. Even if you don't buy into the MVVM pattern itself, the first thing every MVVM framework/toolkit solves is the problem of invoking arbitrary methods in response to UI events (such as Click).
CSLA .NET for Silverlight has the InvokeMethod component that does this. In 3.6/3.7 there are limitations on what it can do.
In 3.8 the limitations are mostly removed, so InvokeMethod can handle any event (as far as I can tell) and can invoke methods on arbitrary objects (as long as they are bindable from XAML).
Also in 3.8 there's a new trigger action named Execute. The Execute action does much of what InvokeMethod does, but within the Blend 3 trigger framework model (which imposes certain limits).
var dp = new DataPortal<Customer>();
dp.FetchCompleted += (o, e) =>
{
// process results (e.Error/e.Object) here
};
dp.BeginFetch();
Copyright (c) Marimer LLC