public void initialise()
 {
     using (var db = new RabbitDbEntities())
     {
         rabbits = db.Rabbits.ToList();
         listGrid1.ItemsSource = rabbits;
     }
 }
 void Initialise()
 {
     using (var db = new RabbitDbEntities())
     {
         rabbits = db.Rabbits.ToList();
         RabbitsList.ItemsSource = rabbits;
     }
 }
        //static Rabbit rabbit = new Rabbit();

        public MainWindow()
        {
            InitializeComponent();
            initialise();


            Save.IsEnabled = false;

            using (var db = new RabbitDbEntities())
            {
                rabbits = db.Rabbits.ToList();
            }
        }
        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
     {
     }
 }