private void OnDelete(object sender, RoutedEventArgs e) { Button btn = sender as Button; if (btn != null) { HostConfig host = btn.CommandParameter as HostConfig; if (host != null) { host.Delete(); Data.Hosts.Remove(host); } } }