本文整理汇总了C#中System.Windows.Controls.ScrollViewer.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# ScrollViewer.ApplyTemplate方法的具体用法?C# ScrollViewer.ApplyTemplate怎么用?C# ScrollViewer.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ScrollViewer
的用法示例。
在下文中一共展示了ScrollViewer.ApplyTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IScrollProvider_VerticalMethods
public void IScrollProvider_VerticalMethods ()
{
ScrollViewer viewer = new ScrollViewer () {
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto
};
AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (viewer);
IScrollProvider p = (IScrollProvider) peer.GetPattern (PatternInterface.Scroll);
viewer.Content = new Button { Width = 1000, Height = 1000 };
CreateAsyncTest (viewer,
() => viewer.ApplyTemplate (),
// Visible and MaxHeight = 0
() => {
viewer.MaxHeight = 0;
viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
},
() => Assert.IsTrue (p.VerticallyScrollable, "#1"),
() => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#2"),
() => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#3"),
// Visible and MaxHeight = 200
() => viewer.MaxHeight = 200,
() => Assert.IsTrue (p.VerticallyScrollable, "#4"),
() => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#5"),
() => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#6"),
// Hidden and MaxHeight = 0
() => {
viewer.MaxHeight = 0;
viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
},
() => Assert.IsTrue (p.VerticallyScrollable, "#7"),
() => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#8"),
() => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#9"),
// Hidden and MaxHeight = 200
() => viewer.MaxHeight = 200,
() => Assert.IsTrue (p.VerticallyScrollable, "#10"),
() => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#11"),
() => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#12"),
// Disabled and MaxHeight = 0
() => {
viewer.MaxHeight = 0;
viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
},
() => Assert.IsFalse (p.VerticallyScrollable, "#13"),
() => Assert.AreEqual (100d, p.VerticalViewSize, "#14"),
() => Assert.AreEqual (0d, viewer.ExtentHeight, "#15"),
() => Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, p.VerticalScrollPercent, "#16"),
// Disabled and MaxHeight = 200
() => viewer.MaxHeight = 200,
() => Assert.IsFalse (p.VerticallyScrollable, "#17"),
() => Assert.AreEqual (100d, p.VerticalViewSize, "#18"),
() => Assert.AreNotEqual (0d, viewer.ExtentHeight, "#19"),
() => Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, p.VerticalScrollPercent, "#20"),
// Auto and MaxHeight = 0
() => {
viewer.MaxHeight = 0;
viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
},
() => Assert.IsTrue (p.VerticallyScrollable, "#21"),
() => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#22"),
() => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#23"),
// Auto and MaxHeight = 200
() => viewer.MaxHeight = 200,
() => Assert.IsTrue (p.VerticallyScrollable, "#24"),
() => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#25"),
() => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#26")
);
}