本文整理汇总了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"),
}
});
}
}
示例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);
}
}
示例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);
}
}