// TODO fiure out a way to call this async and still maintain order // maybe blocking collection + cancellationtokensource private void UpdateDataContext() { if (Content == null || !IsSelected || GetDataContext == null) { return; } // while fetching the dataconext, we will switch IsBusy accordingly using (var token = BusyStack.GetToken()) { var currentContext = Content.DataContext as ObservableObject; var newContext = GetDataContext.Invoke(); if (currentContext == null && newContext == null) { return; } if (EqualityComparer <ObservableObject> .Default.Equals(currentContext, newContext)) { return; } Content.DataContext = newContext; } }
public void BindData(CriteriaOperator filter) { _context.SetFilter("DepartFilter", filter); var context = new GetDataContext { GetData = GetData, Context = SynchronizationContext.Current }; context.GetData.BeginInvoke(new AsyncCallback(AsBindData), context); }
public MainWindow() { DataContext = new MainModel(this); InitializeComponent(); Loaded += (sender, e) => { GetDataContext.StartServer(); }; }