4

任何机构都可以提供我,我们如何为 ScrollViewer 制作自定义模板。

任何简单教程的指针将不胜感激。谢谢,-纳伦德拉

4

2 回答 2

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 看起来与您之前的相同。不同之处在于您现在可以开始使用Template Setter样式来重新排列和自定义ScrollViewer.

于 2010-05-01T12:09:17.047 回答
0

或基于现有 Silverlight 主题构建: http: //timheuer.com/blog/archive/2010/05/03/new-silverlight-4-themes-available-for-download.aspx

于 2010-05-10T16:28:03.770 回答