开发者

Help needed on ScrollViewer styles

Can any body please provide me, how can we made custom template for the ScrollViewer.

Pointers to any simple tutorials will be greatly appreciated. Than开发者_高级运维ks, -Narendra


First thing to do is get yourself a copy of the existing ScrollViewer template. Blend makes that very easy. In VS you have more work to do. Lets start with a base UserControl

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

Got the documentation ScrollViewer Styles and Templates you'll find the existing xaml for this control here. Copy it and place it in the UserControl resources.

<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>

Now the ScrollViewer looks identical to what you had before. The difference is you can now start playing around with the Template Setter in the style to re-arrange and customise the ScrollViewer.


Or build on existing Silverlight themes: http://timheuer.com/blog/archive/2010/05/03/new-silverlight-4-themes-available-for-download.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜