4

ScrollViewer のカスタム テンプレートを作成する方法を教えてください。

簡単なチュートリアルへのポインタは大歓迎です。ありがとう -ナレンドラ

4

2 に答える 2

2

最初に行うことは、既存の ScrollViewer テンプレートのコピーを取得することです。ブレンドはそれをとても簡単にします。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 に答える