public DynamicDataGrid() { var obs = Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => this.Loaded += h, h => this.Loaded -= h).Select(_ => 0); var obs2 = Observable.When(KeyChangeSubject.And(ValueChangeSubject).And(ItemsSourceSubject).Then((a, b, c) => 0)); obs.Amb(obs2) .CombineLatest(KeyChangeSubject.StartWith(Key).DistinctUntilChanged(), (a, b) => b) .CombineLatest(ValueChangeSubject.StartWith(Value).DistinctUntilChanged(), (a, b) => b) .CombineLatest(ItemsSourceSubject.DistinctUntilChanged(), (a, b) => b) .Subscribe(_ => { this.Dispatcher.InvokeAsync(() => this.SetValue(ItemsSourceProperty, DynmamicHelper.OnGetData(_, Key, Value)), System.Windows.Threading.DispatcherPriority.Background, default(System.Threading.CancellationToken)); }); }
public DynamicDataGrid() { //Uri resourceLocater = new Uri("/UtilityWpf.View;component/Themes/DynamicDataGrid.xaml", System.UriKind.Relative); //ResourceDictionary resourceDictionary = (ResourceDictionary)Application.LoadComponent(resourceLocater); //Style = resourceDictionary["DynamicDataGridStyle"] as Style; var obs = Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => this.Loaded += h, h => this.Loaded -= h).Select(_ => 0); var obs2 = Observable.When(KeyChangeSubject.And(ValueChangeSubject).And(ItemsSourceSubject).Then((a, b, c) => 0)); obs.Amb(obs2) .CombineLatest(KeyChangeSubject.StartWith(Key).DistinctUntilChanged(), (a, b) => b) .CombineLatest(ValueChangeSubject.StartWith(Value).DistinctUntilChanged(), (a, b) => b) .CombineLatest(ItemsSourceSubject.DistinctUntilChanged(), (a, b) => b) .Subscribe(_ => { this.Dispatcher.InvokeAsync(() => this.SetValue(ItemsSourceProperty, DynmamicHelper.OnGetData(_, Key, Value)), System.Windows.Threading.DispatcherPriority.Background, default(System.Threading.CancellationToken)); }); }