取消SplitView关闭事件而不停止鼠标事件

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

Cancelling SplitView Close Event without Stopping Mouse Events

问题

我正在开发一个WinUI 3应用程序,我想让我的SplitView.Pane永久保持打开状态。我使用了这个 StackOverflow答案来尝试解决这个问题,但是使用以下代码会停止SplitView的子元素上的所有鼠标事件:

private void SplitView_PaneClosing(SplitView sender, SplitViewPaneClosingEventArgs args)
{
    args.Cancel = true;
}

我的问题是,是否有一种不同的方法可以防止SplitView关闭其面板,或者是否有另一种组件可以让我看起来与SplitView相同,但无法关闭面板。

英文:

I'm working on a WinUI 3 app, and I'd like to have my SplitView.Pane permanently open. I used this StackOverflow answer to try and solve the problem, however doing

private void SplitView_PaneClosing(SplitView sender, SplitViewPaneClosingEventArgs args)
{
    args.Cancel = true;
}

will stop all mouse events to children elements of the SplitView.

My question is whether there is a different way to keep the SplitView from closing its pane, or maybe another component to give me the same look as the SplitView without the pane being able to be closed.

答案1

得分: 2

<SplitView
    DisplayMode="Inline"
    IsPaneOpen="True">
    <SplitView.Pane>
        <TextBlock Text="Pane" />
    </SplitView.Pane>
    <TextBlock Text="Content" />
</SplitView>
英文:

Besides setting IsPaneOpen to True, try setting DisplayMode to Inline.

<SplitView
    DisplayMode="Inline"
    IsPaneOpen="True">
    <SplitView.Pane>
        <TextBlock Text="Pane" />
    </SplitView.Pane>
    <TextBlock Text="Content" />
</SplitView>

huangapple
  • 本文由 发表于 2023年7月4日 21:10:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76613004.html
匿名

发表评论

匿名网友

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

确定