private void ListGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (listGrid1.SelectedItem != null)
     {
         selectedRabbit = (Rabbit)listGrid1.SelectedItem;
         Name.Text      = selectedRabbit.RabbitName.ToString();
         Age.Text       = selectedRabbit.Age.ToString();
         Category.Text  = selectedRabbit.CategoryId.ToString();
     }
 }
        public void populate1000()
        {
            int numberOfRabbitsToCreate = 1000;


            for (int i = 0; i < numberOfRabbitsToCreate; i++)
            {
                using (var db = new RabbitDbEntities())
                {
                    var newRabbit = new Rabbit();
                    db.Rabbits.Add(newRabbit);
                    db.SaveChanges();
                }
            }
        }
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     if ((Save.Content.Equals("Save")) && (selectedRabbit != null))
     {
         using (var db = new RabbitDbEntities())
         {
             var rabbitToUpdate = db.Rabbits.Find(selectedRabbit.RabbitID);
             Save.Background           = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D9C216"));
             Save.Content              = "Edit Mode";
             selectedRabbit            = (Rabbit)listGrid1.SelectedItem;
             rabbitToUpdate.RabbitName = Name.Text;
             db.SaveChanges();
             rabbit = null;
             // clear listbox
             listGrid1.ItemsSource = null; // remove binding
             listGrid1.Items.Clear();      // clear it out
             rabbits = db.Rabbits.ToList();
             listGrid1.ItemsSource = rabbits;
         }
     }
     else
     {
     }
 }