3

私は.NET3.5を使用しているので、タッチスクリーンの優れた機能をすべて備えているわけではありません。私はScrollViewer問題なく動作する独自のタッチスクリーンを作成しました。DocumentViewerそれをテンプレートに組み込みたいのですが、機能しません。テンプレートのバリエーションは次のとおりです。

<Style TargetType="{x:Type DocumentViewer}">
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DocumentViewer}">
                <Border BorderThickness="{TemplateBinding BorderThickness}" 
                        BorderBrush="{TemplateBinding BorderBrush}"
                        Focusable="False">
                    <Grid KeyboardNavigation.TabNavigation="Local">
                        <Grid.Background>
                            <SolidColorBrush Color="{DynamicResource ControlLightColor}" />
                        </Grid.Background>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <ToolBar ToolBarTray.IsLocked="True"
                                 KeyboardNavigation.TabNavigation="Continue"
                                 Visibility="Collapsed">
                            <Button Command="ApplicationCommands.Print"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    Content="Print" />
                            <Button Command="ApplicationCommands.Copy"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    Content="Copy" />
                            <Separator />
                            <Button Command="NavigationCommands.IncreaseZoom"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    Content="Zoom In" />
                            <Button Command="NavigationCommands.DecreaseZoom"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    Content="Zoom Out" />
                            <Separator />
                            <Button Command="NavigationCommands.Zoom"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    CommandParameter="100.0"
                                    Content="Actual Size" />
                            <Button Command="DocumentViewer.FitToWidthCommand"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    Content="Fit to Width" />
                            <Button Command="DocumentViewer.FitToMaxPagesAcrossCommand"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    CommandParameter="1"
                                    Content="Whole Page" />
                            <Button Command="DocumentViewer.FitToMaxPagesAcrossCommand"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                    CommandParameter="2"
                                    Content="Two Pages" />
                        </ToolBar>

                        <custom:TouchScrollViewer x:Name="PART_ContentHost"
                                      Grid.Row="1">
                            <ScrollViewer.Background>
                                <LinearGradientBrush EndPoint="0.5,1"
                                                     StartPoint="0.5,0">
                                    <GradientStop Color="{DynamicResource ControlLightColor}"
                                                  Offset="0" />
                                    <GradientStop Color="{DynamicResource ControlMediumColor}"
                                                  Offset="1" />
                                </LinearGradientBrush>
                            </ScrollViewer.Background>
                        </custom:TouchScrollViewer>

                        <ContentControl Grid.Row="2" x:Name="PART_FindToolBarHost" Visibility="Collapsed"/>
                    </Grid>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

ビューア上で指を動かすとテキストが選択されるだけなので、これは機能しません。テンプレートには、ScrollViewer「PART_ContentHost」という名前の(またはその派生物)が必要です。ScrollViewerその内容の範囲までストレッチするためにをロックする方法はありますか?TouchScrollViewerその後、全体を自分で包むことができますDocumentViewer。または、ドキュメントビューアのヒットテストを非表示にする方法はありますか(つまりIsHItTestVisible = false)。前もって感謝します。

4

0 に答える 0