在 WPF 文档查看器中设置光标

发布于 2024-12-28 21:25:46 字数 1546 浏览 2 评论 0原文

我正在创建一个 WPF 文档查看器,双击该文档将放大页面。为此,我试图让光标在文档查看器中的页面上时变成手,在其他地方时变成箭头。

我的 xaml 设置如下

<UserControl x:Class="WPFXPSViewerControl.XPSControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:UI="clr-namespace:Bluewire.Epro.UI;assembly=EproClientCore"
         xmlns:System="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d"
         Loaded="Window_Loaded"
         Height="1200" MouseDoubleClick="Double_Click">
<Grid Grid.Row="2" Grid.Column="2" Cursor="Hand">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="20" Cursor="Arrow"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <DocumentViewer Name="document" Grid.ColumnSpan="2" Cursor="Arrow">

    </DocumentViewer>
    <Button Width="200" Name="btnZoomIn" Grid.Row="1" Grid.Column="0" Cursor="Hand" Click="btnZoomIn_Click">Zoom In</Button>
    <Button Width="200" Name="btnZoomOut" Grid.Row="1" Grid.Column="1" Cursor="Hand" Click="btnZoomOut_Click">Zoom Out</Button>
</Grid>

</UserControl>

但是,当光标位于页面上时,我似乎无法更改文本光标的默认设置。

I am creating a WPF document viewer that will zoom in to a page when it is double clicked on. To this end I am trying to get the cursor to turn into a hand when over a page in the document viewer, and an arrow when elsewhere.

I have my xaml set up like so

<UserControl x:Class="WPFXPSViewerControl.XPSControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:UI="clr-namespace:Bluewire.Epro.UI;assembly=EproClientCore"
         xmlns:System="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d"
         Loaded="Window_Loaded"
         Height="1200" MouseDoubleClick="Double_Click">
<Grid Grid.Row="2" Grid.Column="2" Cursor="Hand">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="20" Cursor="Arrow"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <DocumentViewer Name="document" Grid.ColumnSpan="2" Cursor="Arrow">

    </DocumentViewer>
    <Button Width="200" Name="btnZoomIn" Grid.Row="1" Grid.Column="0" Cursor="Hand" Click="btnZoomIn_Click">Zoom In</Button>
    <Button Width="200" Name="btnZoomOut" Grid.Row="1" Grid.Column="1" Cursor="Hand" Click="btnZoomOut_Click">Zoom Out</Button>
</Grid>

</UserControl>

However, I cannot seem to change the cursor when it is over a page from its default setting of a text cursor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

因为看清所以看轻 2025-01-04 21:25:46

您可以尝试以下语句:

Cursor="Arrow"  ForceCursor="True"

You could try the following statements:

Cursor="Arrow"  ForceCursor="True"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文