private void DataContextChangedEventHandler(object sender, DependencyPropertyChangedEventArgs e) { if (DataContext != null && DataContext is AllTeamsViewModel) { _viewModel = DataContext as AllTeamsViewModel; } }
public AllTeamsView() { InitializeComponent(); if (DataContext is AllTeamsViewModel) { _viewModel = DataContext as AllTeamsViewModel; } else { DataContextChanged += new DependencyPropertyChangedEventHandler(DataContextChangedEventHandler); } }