/// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            #region load data from XML
            StreamResourceInfo sr = Application.GetResourceStream(new Uri(@"SampleData\restaurants.xml", UriKind.Relative));
            using (TextReader reader = new StreamReader(sr.Stream))
            {
                XmlSerializer serializer  = new XmlSerializer(typeof(ObservableCollection <Restaurant>));
                var           restaurants = (ObservableCollection <Restaurant>)serializer.Deserialize(reader);


                var rt = new Rot13Table();
                foreach (var r in restaurants)
                {
                    Restaurants.Add(r);
                    //r.Text = rt.Transform(r.Text);
                    //r1.Add(r);
                }


                //var serializer1 = new XmlSerializer(typeof(List<Restaurant>));
                //var writer = new System.IO.StringWriter();
                //serializer1.Serialize(writer, r1);
                //var a = writer.ToString();
            }
            #endregion



            this.IsDataLoaded = true;
        }
Пример #2
0
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            #region load data from XML
            StreamResourceInfo sr = Application.GetResourceStream(new Uri(@"SampleData\restaurants.xml", UriKind.Relative));
            using (TextReader reader = new StreamReader(sr.Stream))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ObservableCollection<Restaurant>));
                var restaurants = (ObservableCollection<Restaurant>)serializer.Deserialize(reader);

                var rt = new Rot13Table();
                foreach (var r in restaurants)
                {
                    Restaurants.Add(r);
                    //r.Text = rt.Transform(r.Text);
                    //r1.Add(r);
                }

                //var serializer1 = new XmlSerializer(typeof(List<Restaurant>));
                //var writer = new System.IO.StringWriter();
                //serializer1.Serialize(writer, r1);
                //var a = writer.ToString();
            }
            #endregion

            this.IsDataLoaded = true;
        }