コード例 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var datacontext = new Person()
                {
                    Name = "O Monstro",
                    LastName = "Desmaisons",
                    Local = new Local() { City = "Florianopolis", Region = "SC" },
                    PersonalState = PersonalState.Married
                };

            _FirstSkill = new Skill() { Name = "Langage", Type = "French" };

            datacontext.Skills.Add(_FirstSkill);
            datacontext.Skills.Add(new Skill() { Name = "Info", Type = "C++" });

            Window w = sender as Window;
            w.DataContext = datacontext;
            _Person = datacontext;
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            var datacontext = new Person()
            {
                Name = "O Monstro",
                LastName = "Desmaisons",
                Local = new Local() { City = "Florianopolis", Region = "SC" },
                PersonalState = PersonalState.Married
            };

            var _FirstSkill = new Skill() { Name = "Langage", Type = "French" };

            datacontext.Skills.Add(_FirstSkill);
            datacontext.Skills.Add(new Skill() { Name = "Info", Type = "C++" });

             DataContext = datacontext;
            //_Person = datacontext;
        }
コード例 #3
0
        public void Basic_Option_Simple_UsingRelativePath_AfterDataContext()
        {
            Test((c, w) =>
            {
                var mre = new ManualResetEvent(false);

                DisplayEvent de = null;
                EventHandler<DisplayEvent> ea = null;
                ea = (o, e) => { de = e; c.OnDisplay -= ea; };
                c.OnDisplay += ea;
                var dc = new Person();

                string relp = "javascript\\navigation_1.html";
                string path = string.Format("{0}\\{1}", typeof(HTMLViewControl).Assembly.GetPath(), relp);
                var jvs = PrepareFiles();

                //<script src="src\knockout.js" type="text/javascript"></script>
                //<script src="src\Ko_Extension.js" type="text/javascript"></script>
                //<script src="src\Ko_register.js" type="text/javascript"></script>

                w.RunOnUIThread(() =>
                {
                    c.Mode = JavascriptBindingMode.OneWay; 
                    w.Window.DataContext = dc;
                    c.RelativeSource = relp;
                    mre.Set();
                });

                mre.WaitOne();

                Thread.Sleep(2000);
                foreach (string jv in jvs)
                {
                    string p = string.Format("{0}\\javascript\\src\\{1}", typeof(HTMLViewControl).Assembly.GetPath(), jv);
                    File.Delete(p);
                }
                File.Delete(path);
                de.Should().NotBeNull();
                de.DisplayedViewModel.Should().Be(dc);


            });
        }
コード例 #4
0
        public void Basic_Option_Simple()
        {
            Test((c, w) =>
            {
                var mre = new ManualResetEvent(false);

                DisplayEvent de = null;
                EventHandler<DisplayEvent> ea = null;
                ea = (o, e) => { de = e; c.OnDisplay -= ea; };
                c.OnDisplay += ea;
                var dc = new Person();

                w.RunOnUIThread(() =>
                {
                    c.Mode = JavascriptBindingMode.OneWay;
                    string relp = "javascript\\navigation_1.html";
                    c.Uri = new Uri(string.Format("{0}\\{1}", Assembly.GetAssembly(typeof(Test_HTMLViewControl)).GetPath(), relp));
                    w.Window.DataContext = dc;
                    mre.Set();
                });

                mre.WaitOne();

                Thread.Sleep(2500);
                de.Should().NotBeNull();
                de.DisplayedViewModel.Should().Be(dc);


            });
        }