2011-12-05 7 views
0

グリッドにはいくつかのテキストボックスがあります。私はこのグリッドを私のメインウィンドウの一番下に固定しておきたい。したがって、ユーザーがスクロールするとグリッドは基本的にその場所に留まります。可視領域にコントロールを保持する

これを行う方法の1つは、ScrollViewerから値を取得し、それをグリッドCanvas.TopPropertyに追加することでした。しかし、ユーザーがスクロールアップまたはスクロールしたときにどの値が変更されるかはわかりません。

答えて

3

メインウィンドウにスクロールしないでください。 ScrollViewerは、スクロールするコンテンツ(行)にのみ配置します。 ScrollViewerまたはコンテナで行の高さにautoを使用しないように注意すると、すべてのコンテンツをサポートするようになり、Scrollが機能しなくなります。

0

一つの方法:

<Window x:Class="Sample.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window1" Height="300" Width="300"> 
<Grid> 
    <ListBox> 
     <!--Hardcoded listbox items just to force the scrollbar for demonstration purposes --> 
     <ListBoxItem>Item1</ListBoxItem> 
     <ListBoxItem>Item2</ListBoxItem> 
     <ListBoxItem>Item3</ListBoxItem> 
     <ListBoxItem>Item4</ListBoxItem> 
     <ListBoxItem>Item5</ListBoxItem> 
     <ListBoxItem>Item6</ListBoxItem> 
     <ListBoxItem>Item7</ListBoxItem> 
     <ListBoxItem>Item8</ListBoxItem> 
     <ListBoxItem>Item9</ListBoxItem> 
     <ListBoxItem>Item10</ListBoxItem> 
     <ListBoxItem>Item11</ListBoxItem> 
     <ListBoxItem>Item12</ListBoxItem> 
     <ListBoxItem>Item14</ListBoxItem> 
     <ListBoxItem>Item15</ListBoxItem> 
     <ListBoxItem>Item16</ListBoxItem> 
     <ListBoxItem>Item17</ListBoxItem> 
     <ListBoxItem>Item18</ListBoxItem> 
     <ListBoxItem>Item19</ListBoxItem> 
     <ListBoxItem>Item20</ListBoxItem> 
     <ListBoxItem>Item21</ListBoxItem> 
     <ListBoxItem>Item22</ListBoxItem> 
    </ListBox> 
    <Grid Panel.ZIndex="5" VerticalAlignment="Bottom" Background="DarkGray"> 
     <StackPanel> 
      <TextBox HorizontalAlignment="Left" VerticalAlignment="Center">Text box 1</TextBox> 
      <TextBox HorizontalAlignment="Left" VerticalAlignment="Center">Text box 2</TextBox> 
      <TextBox HorizontalAlignment="Left" VerticalAlignment="Center">Text box 3</TextBox> 
     </StackPanel> 
    </Grid> 
</Grid>