public CollectionEditor() : base() { Uri resourceLocater = new Uri("/UtilityWpf.View;component/Themes/CollectionEditor.xaml", System.UriKind.Relative); ResourceDictionary resourceDictionary = (ResourceDictionary)Application.LoadComponent(resourceLocater); Style = resourceDictionary["CollectionEditorStyle"] as Style; //DeletedSubject.OnNext(new object()); //NewItemS //Observable.FromEventPattern<EventHandler, EventArgs>(_ => this.Initialized += _, _ => this.Initialized -= _) // .CombineLatest(NewItemsSubject, (a, b) => b) // .CombineLatest(KeySubject, (item, key) => new { item, key }) // .Subscribe(_ => React(_.item, _.key)); var obs = ItemsSourceSubject.Where(_ => _ != null) .Take(1) .Select(_ => (_.First())) .Concat(SelectedItemSubject) .DistinctUntilChanged(); InputSubject.WithLatestFrom(obs, (input, item) => new { input, item }) .Subscribe(_ => { switch (_.input) { case (DatabaseCommand.Delete): DeletedSubject.OnNext(_.item); break; case (DatabaseCommand.Update): break; case (DatabaseCommand.Clear): ClearedSubject.OnNext(null); break; } }); Action <DatabaseCommand> av = (a) => this.Dispatcher.InvokeAsync(() => InputSubject.OnNext(a), System.Windows.Threading.DispatcherPriority.Background, default(System.Threading.CancellationToken)); var items = ButtonDefinitionHelper.GetCommandOutput <DatabaseCommand>(typeof(DatabaseCommand)) ?.Select(meas => new ViewModel.ButtonDefinition { Command = new RelayCommand(() => av(meas.Value())), Content = meas.Key }); if (items == null) { Console.WriteLine("measurements-service equals null in collectionviewmodel"); } else { this.Dispatcher.InvokeAsync(() => Buttons = items.ToList(), System.Windows.Threading.DispatcherPriority.Background, default(System.Threading.CancellationToken)); } }
private void UpdateButtons() { var items = ButtonDefinitionHelper.GetCommandOutput(Type, OutputType, Parameters)? .Select(kvp => new ButtonDefinition { Command = new RelayCommand(() => SetOuput(kvp.Value())), Content = kvp.Key }); if (items == null) { Console.WriteLine("measurements-service equals null in collectionviewmodel"); } this.Dispatcher.InvokeAsync(() => ItemsSource = items.ToList(), System.Windows.Threading.DispatcherPriority.Background, default(System.Threading.CancellationToken)); void SetOuput(object a) =>/* _output.OnNext(a)*/ this.Dispatcher.InvokeAsync(() => Output = a, System.Windows.Threading.DispatcherPriority.Background, default(System.Threading.CancellationToken)); }