0

WPF スクロールビューアーの境界外で要素を変換した場合、それを一番上にレンダリングできないようです。

次の例を検討してください。

<Window x:Class="ScrollViewerContentTransform.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>

         <Grid.RowDefinitions>
             <RowDefinition/>
             <RowDefinition/>
         </Grid.RowDefinitions>

         <Border Grid.Row="0" Background="Blue" Panel.ZIndex="1"/>

         <ScrollViewer Grid.Row="1" Panel.ZIndex="2">
             <Grid>
                 <Border Width="30" Height="30" Background="Red">
                     <Border.RenderTransform>
                         <TranslateTransform Y="-80"/>
                     </Border.RenderTransform>
                 </Border>
             </Grid>
         </ScrollViewer>

    </Grid>
</Window>

zorder を設定しても、赤い境界線は青い境界線の下にまだ隠されています。

http://imm.io/Sm2Q

ScrollViewer を Grid に置き換えると、必要に応じて表示されます。ScrollViewer を使用するときに要素を一番上に表示する方法に関するヒントはありますか?

4

1 に答える 1

1

As far as I know, it is impossible to remove content clipping when using ScrollViewer, because the ScrollViewer control template will generate a ScrollContentPresenter which in turn has the following implementation of the GetLayoutClip method:

protected override Geometry GetLayoutClip(Size layoutSlotSize) {
    return new RectangleGeometry(new Rect(base.RenderSize));
}

This class is Sealed so you can't derive from it to override this method. Thus consider removing ScrollViewer from your layout.

于 2013-01-10T14:24:48.883 に答える