Help in ScrollViewer styles

Can any body provide me with how we can create our own template for ScrollViewer.

Pointers to any simple guides would be greatly appreciated. Thanks, -Narendra

+4
source share
2 answers

The first thing to do is get a copy of the existing ScrollViewer template. Blend makes it very simple. In VS you have more work. Let's start with the UserControl base

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

After you get the ScrollViewer Styles and Templates documentation, you will find the existing xaml for this control here. Copy it and put it in 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> 

ScrollViewer now looks the same as before. The difference is that you can now start playing with the Template Setter in style to ScrollViewer and customize the ScrollViewer .

+2
source

Source: https://habr.com/ru/post/1308532/


All Articles