2010-05-01 129 views

回答

2

首先要做的就是让自己的ScrollViewer模板的副本。 Blend使这非常简单。在VS你有更多的工作要做。让我们开始基本UserControl

<UserControl ....> 
    <Grid x:Name="LayoutRoot"> 
    <ScrollViewer ...> 
     <!-- Content here --> 
    </ScrollViewer> 
    </Grid> 
</UserControl> 

得到的文档ScrollViewer Styles and Templates,你会发现这里这种控制现有的XAML。将其复制并放入UserControl资源中。

<UserControl ....> 
    <UserControl.Resources> 
    <Style x:Key="MyScrollViewerStyle" TargetType="ScrollViewer"> 
     <!-- copied content of the style from the above link --> 
    </Style> 
    </UserControl.Resources> 
    <Grid ....> 
    <Grid x:Name="LayoutRoot"> 
    <ScrollViewer Style="{StaticResource MyScrollViewerStyle}"> 
     <!-- Content here --> 
    </ScrollViewer> 

现在ScrollViewer看起来和以前一样。不同的是,你现在可以开始玩TemplateSetter的风格来重新安排和定制ScrollViewer