Ejemplo n.º 1
0
        public MainViewModel()
        {
            dynamic song = new SongViewModel {
                Performer = "Journey", Title = "Don't Stop Believing",
            };

            Songs = new DynamicObservableCollection <SongViewModel>
            {
                song,
                new SongViewModel {
                    Performer = "Styx", Title = "Rockin' the Paradise",
                },
                new SongViewModel {
                    Performer = "Led Zepplin", Title = "Stairway to Heaven",
                },
            };

            Songs[1].Composer = "Dennis DeYoung";

            Songs[0].Length = new TimeSpan(0, 0, 4, 11);
            Songs[1].Length = new TimeSpan(0, 0, 3, 35);
            Songs[2].Length = new TimeSpan(0, 0, 8, 02);

            dynamic other = new OtherViewModel {
                Thing = "Hello World",
            };

            other.AddProperty("FizzBin", typeof(int), "Fizzy Bin");

            other.FizzBin = 5;
            other.Muskrat = "Sweet Moses";

            Others = new DynamicObservableCollection <OtherViewModel>
            {
                other,
                new OtherViewModel {
                    Thing = "Is Cool?",
                },
            };

            object value = 85.156;

            other.AddValue("Moose", "My Moose", value);
        }
Ejemplo n.º 2
0
 private static IList CreateDynamicCollection(IList<object> collection)
 {
     var representativeItem = collection[0] as DynamicObject;
     var newCollection = new DynamicObservableCollection<DynamicObject>(representativeItem);
     foreach (var item in collection) newCollection.Add(item as DynamicObject);
     return newCollection;
 }