Cursor Not Changing on GridSplitter – Community Toolkit

huangapple go评论52阅读模式
英文:

Cursor Not Changing on GridSplitter - Community Toolkit

问题

尝试使用Community Toolkit GridSplitter,但当我悬停在分隔栏上时,光标不会更改。更改GripperCursor或CursorBehavior属性没有效果。它仍然保持默认的光标。

当单击并拖动时,它会调整窗格的大小,但鼠标光标的行为不如预期。

我正在使用以下包:

  • WindowsAppSDK 1.3.2305,
  • CommunityToolkit.WinUI.UI 7.1.2,
  • CommunityToolkit.WinUI.UI.Controls.Layout 7.1.2
<Page
    x:Class="AppPrototypes.Views.GridSplitter"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AppPrototypes.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
    mc:Ignorable="d"
    >

    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition MinHeight="100"  />
            <RowDefinition Height="Auto"/>
            <RowDefinition MinHeight="100"/>
        </Grid.RowDefinitions>
       
        <Grid Grid.Row="0">
            <TextBlock Margin=" 10 10 0 0" Text="顶部行。
                       这段文字用于模拟网格的调整大小功能" />
        </Grid>
        
        <controls:GridSplitter Grid.Row="1"
            GripperCursor="UniversalNo"
            CursorBehavior="ChangeOnGripperHover"  />

        <Grid Grid.Row="2">
            <TextBlock Text="底部行。
                       这段文字用于模拟网格的调整大小功能" />
        </Grid>
    </Grid>
</Page>
英文:

Trying out the Community Toolkit GridSplitter, but the cursor does not change when I hover over the splitter bar. Changing the GripperCursor or CursorBehavior properties has no effect. It stays with the default cursor.

It resizes the panes when clicked and dragged, but the mouse cursor does not behave as expected.

I am using packages
WindowsAppSDK 1.3.2305,
CommunityToolkit.WinUI.UI 7.1.2 and
CommunityToolkit.WinUI.UI.Controls.Layout 7.1.2

<Page
    x:Class="AppPrototypes.Views.GridSplitter"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AppPrototypes.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
    mc:Ignorable="d"
    >

    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition MinHeight="100"  />
            <RowDefinition Height="Auto"/>
            <RowDefinition MinHeight="100"/>
        </Grid.RowDefinitions>
       
        <Grid Grid.Row="0">
            <TextBlock Margin=" 10 10 0 0" Text="Top Row.    
                       This text to simulate the resizing feature of the Grid" />
        </Grid>
        
        <controls:GridSplitter Grid.Row="1"
            GripperCursor="UniversalNo"
            CursorBehavior="ChangeOnGripperHover"  />

        <Grid Grid.Row="2">
            <TextBlock Text="Bottom Row.     
                       This text to simulate the resizing feature of the Grid" />
        </Grid>
    </Grid>
</Page>

答案1

得分: 1

I'm not sure but I guess the cursor of the GridSplitter doesn't work on WinUI 3 apps.

You should try the GridSplitter from the CommunityToolkit.Labs.WinUI.SizerBase NuGet package. I can confirm that its cursor works.

  1. Add a new NuGet package source.

    Feed URL: https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json

  2. Temporarily, disable other package sources, including nuget.org.
    I don't know why but I couldn't install the CommunityToolkit.Labs.WinUI.SizerBase with other sources enabled.

  3. Enable Include prerelease.

  4. Add the CommunityToolkit.Labs.WinUI.SizerBase package.

And use it like this:

<Page
    x:Class="GridSplitterExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:CommunityToolkit.Labs.WinUI"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:GridSplitterExample"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    mc:Ignorable="d">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition MinHeight="100" />
            <RowDefinition Height="Auto" />
            <RowDefinition MinHeight="100" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <TextBlock
                Margin="10,10,0,0"
                Text="Top Row." />
        </Grid>

        <controls:GridSplitter
            Grid.Row="1"
            Cursor="UniversalNo" />

        <Grid Grid.Row="2">
            <TextBlock Text="Bottom Row." />
        </Grid>
    </Grid>
</Page>
英文:

I'm not sure but I guess the cursor of the GridSplitter doesn't work on WinUI 3 apps.

You should try the GridSplitter from the CommunityToolkit.Labs.WinUI.SizerBase NuGet package. I can confirm that its cursor works.

  1. Add a new NuGet package source.

    Feed URL: https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json

  2. Temporarily, disable other package sources, including nuget.org.
    I don't know why but I couldn't install the CommunityToolkit.Labs.WinUI.SizerBase with other sources enabled.

  3. Enable Include prerelease.

  4. Add the CommunityToolkit.Labs.WinUI.SizerBase package.

And use it like this:

&lt;Page
    x:Class=&quot;GridSplitterExample.MainPage&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:controls=&quot;using:CommunityToolkit.Labs.WinUI&quot;
    xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
    xmlns:local=&quot;using:GridSplitterExample&quot;
    xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
    Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;
    mc:Ignorable=&quot;d&quot;&gt;

    &lt;Grid&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition MinHeight=&quot;100&quot; /&gt;
            &lt;RowDefinition Height=&quot;Auto&quot; /&gt;
            &lt;RowDefinition MinHeight=&quot;100&quot; /&gt;
        &lt;/Grid.RowDefinitions&gt;

        &lt;Grid Grid.Row=&quot;0&quot;&gt;
            &lt;TextBlock
                Margin=&quot;10,10,0,0&quot;
                Text=&quot;Top Row.&quot; /&gt;
        &lt;/Grid&gt;

        &lt;controls:GridSplitter
            Grid.Row=&quot;1&quot;
            Cursor=&quot;UniversalNo&quot; /&gt;

        &lt;Grid Grid.Row=&quot;2&quot;&gt;
            &lt;TextBlock Text=&quot;Bottom Row.&quot; /&gt;
        &lt;/Grid&gt;
    &lt;/Grid&gt;
&lt;/Page&gt;

huangapple
  • 本文由 发表于 2023年6月8日 20:47:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76432008.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定