2010-05-01 123 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