using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace ComboBoxWPF { /// /// Interaktionslogik für MainWindow.xaml /// public partial class MainWindow : Window { ViewModel CurrentViewModel; public MainWindow() { this.Loaded += MainWindow_Loaded; InitializeComponent(); ViewModel viewModel = this.DataContext as ViewModel; CurrentViewModel = (ViewModel)(this.Resources["vm"]); string cb_State = ((ComboBoxItem)cbStatus.SelectedItem).Tag.ToString(); CurrentViewModel.CBStatus = (ComboBoxItem)cbStatus.SelectedItem; } private void CbStatus_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (CurrentViewModel != null) CurrentViewModel.ComboChanged(); } private void MainWindow_Loaded(object sender, RoutedEventArgs e) { CurrentViewModel = (ViewModel)(this.Resources["vm"]); } } }