Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 2.68 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to keep elements in ScrollViewer in sight, regardless of scrolling
  2. <Page
  3.   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4.   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  5.   <Grid>  
  6.     <ScrollViewer Width="250" Height="100" HorizontalScrollBarVisibility="Visible">
  7.       <StackPanel>
  8.         <Grid Width="350" Height="50">
  9.           <Grid.ColumnDefinitions>
  10.             <ColumnDefinition Width="50" />
  11.             <ColumnDefinition Width="50" />
  12.             <ColumnDefinition Width="50" />
  13.             <ColumnDefinition Width="50" />
  14.             <ColumnDefinition Width="50" />
  15.             <ColumnDefinition Width="50" />
  16.             <ColumnDefinition Width="50" />
  17.           </Grid.ColumnDefinitions>
  18.           <Button Content="1" Grid.Column="0" BorderThickness="2" Width="50" />
  19.           <Button Content="2" Grid.Column="1" BorderThickness="2" Width="50" />
  20.           <Button Content="3" Grid.Column="2" BorderThickness="2" Width="50" />
  21.           <Button Content="4" Grid.Column="3" BorderThickness="2" Width="50" />
  22.           <Button Content="5" Grid.Column="4" BorderThickness="2" Width="50" />
  23.           <Button Content="6" Grid.Column="5" BorderThickness="2" Width="50" />
  24.           <Button Content="X" Grid.Column="6" BorderThickness="2" Width="50" />
  25.         </Grid>
  26.         <Grid Width="350" Height="50">
  27.           <Grid.ColumnDefinitions>
  28.             <ColumnDefinition Width="50" />
  29.             <ColumnDefinition Width="50" />
  30.             <ColumnDefinition Width="50" />
  31.             <ColumnDefinition Width="50" />
  32.             <ColumnDefinition Width="50" />
  33.             <ColumnDefinition Width="50" />
  34.             <ColumnDefinition Width="50" />
  35.           </Grid.ColumnDefinitions>
  36.           <Button Content="1" Grid.Column="0" BorderThickness="2" Width="50" />
  37.           <Button Content="2" Grid.Column="1" BorderThickness="2" Width="50" />
  38.           <Button Content="3" Grid.Column="2" BorderThickness="2" Width="50" />
  39.           <Button Content="4" Grid.Column="3" BorderThickness="2" Width="50" />
  40.           <Button Content="5" Grid.Column="4" BorderThickness="2" Width="50" />
  41.           <Button Content="6" Grid.Column="5" BorderThickness="2" Width="50" />
  42.           <Button Content="X" Grid.Column="6" BorderThickness="2" Width="50" />
  43.         </Grid>
  44.       </StackPanel>
  45.     </ScrollViewer>
  46.   </Grid>
  47. </Page>
  48.        
  49. <Grid>
  50.   <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="5">
  51.      <Button Content="Button1"/>
  52.      <Button Content="Button1"/>
  53.      <Button Content="Button1"/>
  54.      <Button Content="Button1"/>
  55.      <Button Content="Button1"/>
  56.   </StackPanel>
  57.   <ScrollViewer>
  58.      ... Scroll Viewer Embedded Stuff ...
  59.   </ScrollViewer>
  60. </Grid>