private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { try { XmlSerializer xmlSerializer = new XmlSerializer(typeof(GarbageCan)); using (Stream stream = File.Open(GarbagecanXML, FileMode.OpenOrCreate)) { m_GarbageCan = (GarbageCan)xmlSerializer.Deserialize(stream); } } catch (Exception) { m_GarbageCan = new GarbageCan(); } DataContext = m_GarbageCan; EverythingWraper.StartEverything(); }