private void RefreshView()
{
// when the PlottedProperty changes we need to recompute our bindings. However,
// the legend is bound to the collection items, the properties of which have not changes.
// Therefore, we use a bit of an ugly hack to fool the legend into thinking the datacontext
// has changed which causes it to replot itself.
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
(ThreadStart)(() =>
{
object context = legend.DataContext;
if (context != null)
{
legend.DataContext = null;
legend.DataContext = context;
}
}));
}