具有非滚动区域的ScrollViewer(固定标题) [英] ScrollViewer with non scrolling area (fixed header)
本文介绍了具有非滚动区域的ScrollViewer(固定标题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何使用具有固定标题的ScrollViewer(例如GridView中的Column标题).
<
ScrollViewer >< StackPanel >
标签 内容 = " 标题 " />
... ...某些内容...
</ StackPanel >
</ ScrollViewer > >
最诚挚的问候,
托马斯·安德森(Thomas Andersen)
解决方案
您可以改装HeaderedContentControl来满足自己的需求:
页面 xmlns = " "
xmlns:x = " http://schemas.microsoft.com/winfx/2006/xaml ">
< Page.Resources ControlTemplate = HeaderedContentControl " x:Key " myControlTemplate " StackPanel >
< ContentSource = " "
/span> ContentTemplate = {TemplateBinding HeaderedContentControl.HeaderTemplate} "
= {TemplateBinding HeaderedContentControl.Header} " ScrollViewer ContentTemplate = {TemplateBinding ContentControl.ContentTemplate} = {TemplateBinding ContentControl.Content} " StackPanel >
</ ControlTemplate Page.Resources >
< HeaderedContentControl 页眉 " &; 模板 = " " <!- ->
</ >
< / 页面 >
How can I have a ScrollViewer with a fixed header (like the Column headers in a GridView).
<
ScrollViewer>
<StackPanel>
<Label Content="Header" />
...Some content...
</StackPanel>
</ScrollViewer>Best regards,
Thomas Andersen解决方案You can retrofit HeaderedContentControl to meet your own needs:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources><ControlTemplate TargetType="HeaderedContentControl" x:Key="myControlTemplate"><StackPanel><ContentPresenterContentSource="Header"ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"Content="{TemplateBinding HeaderedContentControl.Header}"/><ScrollViewer ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"Content="{TemplateBinding ContentControl.Content}"/></StackPanel></ControlTemplate></Page.Resources><HeaderedContentControl Header="HeaderText" Template="{StaticResource myControlTemplate}"><!--Put your content here--></HeaderedContentControl></Page>
这篇关于具有非滚动区域的ScrollViewer(固定标题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文