Search code examples
c#xamlwinui-3panesplitview

Cancelling SplitView Close Event without Stopping Mouse Events


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.


Solution

  • 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>