コード例 #1
0
ファイル: XamlIlTests.cs プロジェクト: yuyu2you/Avalonia
        public void Event_Handlers_Should_Work_For_Templates()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow))
            {
                var w = new XamlIlBugTestsEventHandlerCodeBehind();
                w.ApplyTemplate();
                w.Show();

                Dispatcher.UIThread.RunJobs();
                var itemsPresenter = ((ItemsControl)w.Content).GetVisualChildren().FirstOrDefault();
                var item           = itemsPresenter
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First();

                ((Control)item).DataContext = "test";
                Assert.Equal("test", w.SavedContext);
            }
        }
コード例 #2
0
        public void Event_Handlers_Should_Work_For_Templates()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow))
            {
                var w = new XamlIlBugTestsEventHandlerCodeBehind();
                w.ApplyTemplate();
                w.Show();

                Dispatcher.UIThread.RunJobs();
                var itemsPresenter = ((ItemsControl)w.Content).GetVisualChildren().FirstOrDefault();
                var item           = itemsPresenter
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First();
                ((Control)item).RaiseEvent(new PointerPressedEventArgs {
                    ClickCount = 20
                });
                Assert.Equal(20, w.Args.ClickCount);
            }
        }