Exemplo n.º 1
0
        public MainWindow()
        {
            if (_peopleInfo == null)
            {
                if (File.Exists("Info.xml"))
                {
                    using (var stream = File.OpenRead("Info.xml"))
                    {
                        if (stream.Length != 0)
                        {
                            // 这里PeopleInfo的权限需要为public,否则会报错
                            var serializer = new XmlSerializer(typeof(PeopleInfo));
                            _peopleInfo = serializer.Deserialize(stream) as PeopleInfo;
                        }
                        else
                        {
                            _peopleInfo = new PeopleInfo();
                        }
                    }
                }
                else
                {
                    _peopleInfo = new PeopleInfo();
                }
            }

            DataContext = _peopleInfo;

            InitializeComponent();

            for (int i = 1; i < 200; i++)
            {
                TxtBlockOutpuMessage.Inlines.Add(new Run(i.ToString()));
                // TxtBlockOutpuMessage.Inlines.Add(new LineBreak());
            }
        }
Exemplo n.º 2
0
 private void ButtonCancle_Click(object sender, RoutedEventArgs e)
 {
     _peopleInfo = null;
     Close();
 }