ScrollViewer のカスタム テンプレートを作成する方法を教えてください。
簡単なチュートリアルへのポインタは大歓迎です。ありがとう -ナレンドラ
ScrollViewer のカスタム テンプレートを作成する方法を教えてください。
簡単なチュートリアルへのポインタは大歓迎です。ありがとう -ナレンドラ
最初に行うことは、既存の 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
です。
または、既存の Silverlight テーマに基づいて構築します: http://timheuer.com/blog/archive/2010/05/03/new-silverlight-4-themes-available-for-download.aspx