private void menuItemToggleSyncEnabled_Click(object sender, RoutedEventArgs e) { DisplayProduct productInfo = listViewProducts.SelectedItem as DisplayProduct; if (productInfo != null) { ClientLogic clientLogic = this.DataContext as ClientLogic; Debug.Assert(clientLogic != null); clientLogic.AdminSetProductSyncState(productInfo.Id, !productInfo.SynchronizeEnabled); e.Handled = true; } }