Ejemplo n.º 1
0
        public MainViewModel()
        {
            var cvm1 = new MyObject();
               cvm1.ID = 12345;

               var cvm2 = new MyObject();
               cvm2.ID = 54321;

               var cvm3 = new MyObject();
               cvm3.ID = 15243;

               SillyStuff = new ObservableCollection<MyObject>();
               SillyStuff.Add(cvm1);
               SillyStuff.Add(cvm2);
               SillyStuff.Add(cvm3);
        }
 private void B_Click(object sender, RoutedEventArgs e)
 {
     var lv = (sender as Button)?.Content as MyObject;
        if (selectedLV != null) {
     lv.IsSelected = false;
     if ((selectedLV.Content as MyObject) == SelectedLocation) {
      SelectedLocation = null;
      selectedLV = null;
     }
        }
        if (lv != null) {
     SelectedLocation = lv;
     selectedLV = sender as Button;
     lv.IsSelected = true;
        }
 }