BetterExplorer.PieChart.Legend.RefreshView C# (CSharp) Method

RefreshView() private method

Refreshes the view, re-computing any value which is derived from the data bindings
private RefreshView ( ) : void
return void
        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;
                                                        }
                                                    }));
        }