当前位置: 首页>>代码示例>>C#>>正文


C# Window.ApplyTemplate方法代码示例

本文整理汇总了C#中Window.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# Window.ApplyTemplate方法的具体用法?C# Window.ApplyTemplate怎么用?C# Window.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Window的用法示例。


在下文中一共展示了Window.ApplyTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyStyling

        public ApplyStyling()
        {
            _app = UnitTestApplication.Start(TestServices.StyledWindow);

            TextBox textBox;

            _window = new Window
            {
                Content = textBox = new TextBox(),
            };

            _window.ApplyTemplate();
            textBox.ApplyTemplate();

            var border = (Border)textBox.GetVisualChildren().Single();

            if (border.BorderThickness != 2)
            {
                throw new Exception("Styles not applied.");
            }

            _window.Content = null;

            // Add a bunch of styles with lots of class selectors to complicate matters.
            for (int i = 0; i < 100; ++i)
            {
                _window.Styles.Add(new Style(x => x.OfType<TextBox>().Class("foo").Class("bar").Class("baz"))
                {
                    Setters = new[]
                    {
                        new Setter(TextBox.TextProperty, "foo"),
                    }
                });
            }
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:35,代码来源:ApplyStyling.cs

示例2: HotKeyManager_Should_Register_And_Unregister_Key_Binding

        public void HotKeyManager_Should_Register_And_Unregister_Key_Binding()
        {
            using (PerspexLocator.EnterScope())
            {
                var windowImpl = new Mock<IWindowImpl>();
                var styler = new Mock<Styler>();

                PerspexLocator.CurrentMutable
                    .Bind<IWindowImpl>().ToConstant(windowImpl.Object)
                    .Bind<IStyler>().ToConstant(styler.Object);

                var gesture1 = new KeyGesture {Key = Key.A, Modifiers = InputModifiers.Control};
                var gesture2 = new KeyGesture {Key = Key.B, Modifiers = InputModifiers.Control};

                var tl = new Window();
                var button = new Button();
                tl.Content = button;
                tl.Template = CreateWindowTemplate();
                tl.ApplyTemplate();

                HotKeyManager.SetHotKey(button, gesture1);

                Assert.Equal(gesture1, tl.KeyBindings[0].Gesture);

                HotKeyManager.SetHotKey(button, gesture2);
                Assert.Equal(gesture2, tl.KeyBindings[0].Gesture);

                tl.Content = null;
                tl.Presenter.ApplyTemplate();

                Assert.Empty(tl.KeyBindings);

                tl.Content = button;
                tl.Presenter.ApplyTemplate();

                Assert.Equal(gesture2, tl.KeyBindings[0].Gesture);

                HotKeyManager.SetHotKey(button, null);
                Assert.Empty(tl.KeyBindings);

            }
        }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:42,代码来源:HotKeyManagerTests.cs

示例3: Container_Child_Should_Have_LogicalParent_Set_To_Container

        public void Container_Child_Should_Have_LogicalParent_Set_To_Container()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow))
            {
                var root = new Window();
                var target = new ItemsControl();

                root.Content = target;

                var templatedParent = new Button();
                target.TemplatedParent = templatedParent;
                target.Template = GetTemplate();

                target.Items = new[] { "Foo" };

                root.ApplyTemplate();
                target.ApplyTemplate();
                target.Presenter.ApplyTemplate();

                var container = (ContentPresenter)target.Presenter.Panel.Children[0];

                Assert.Equal(container, container.Child.Parent);
            }
        }
开发者ID:jazzay,项目名称:Avalonia,代码行数:24,代码来源:ItemsControlTests.cs


注:本文中的Window.ApplyTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。