Justin Finch's Blog
My Links
Blog Stats
  • Posts - 7
  • Stories - 0
  • Comments - 0
  • Trackbacks - 1
Archives

Monday, March 19, 2007

I have recently been working on a WPF touch screen application that doesn’t lend it self well to normal scroll bars.  Luckly this is no problem with WPF because you have the ability to easily modify how a control is rendered.  Below is a rough template that puts a button above and below scrollable content and when clicked they provide the same functionality as the default scroll bar.

 

<ControlTemplate TargetType="{x:Type ScrollViewer}"   
 
x:Key="ButtonOnlyScrollViewer">

<Grid>

<Grid.RowDefinitions>

<RowDefinition Height="Auto"/>

<RowDefinition Height="*"/>

<RowDefinition Height="Auto"/>

Grid.RowDefinitions>

<Grid.ColumnDefinitions>

<ColumnDefinition />

<ColumnDefinition />

Grid.ColumnDefinitions>

<RepeatButton Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch"
 
Content="ScrollUp"Command="ScrollBar.LineUpCommand"/>

<ScrollContentPresenter Grid.Row="1" Content="{TemplateBinding Content}"  
 
Grid.Column="0" ScrollViewer.VerticalScrollBarVisibility ="Auto"  
 
Height="Auto" Margin="{TemplateBinding Margin}"/>

<RepeatButton Grid.Row="2" Grid.Column="0" Height="20"
 
Content="ScrollDown"

  Command="ScrollBar.LineDownCommand"/>

Grid>

ControlTemplate>

posted @ 4:00 PM | Feedback (0)
Justin Finch