dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.05k stars 1.17k forks source link

WPF + WEBVIEW #9845

Open ludelues opened 1 week ago

ludelues commented 1 week ago

Description

I can create a perfect application using a WPF and Blazor hybrid, but there is one drawback:

The resize area of the WPF window is too narrow. While adding padding can make it wider, it makes the window look unattractive.

Reproduction Steps

<Window x:Class="MyTalk.WpfPages.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:MyTalk" xmlns:pages="clr-namespace:MyTalk.Pages" mc:Ignorable="d"

    xmlns:blazor="clr-namespace:Microsoft.AspNetCore.Components.WebView.Wpf;assembly=Microsoft.AspNetCore.Components.WebView.Wpf"

    xmlns:ui="http://schemas.modernwpf.com/2019"
    ui:WindowHelper.UseModernWindowStyle="True"
    ui:TitleBar.ExtendViewIntoTitleBar="True"

    Height="888" Width="450">

<Border>
    <blazor:BlazorWebView HostPage="wwwroot\index.html" Services="{DynamicResource services}" >
        <blazor:BlazorWebView.RootComponents>
            <blazor:RootComponent Selector="#app" ComponentType="{x:Type local:Route}" />
        </blazor:BlazorWebView.RootComponents>
    </blazor:BlazorWebView>
</Border>

Expected behavior

The resize area of the WPF window should be sufficiently wide to allow easy resizing without requiring additional padding. This would enable users to resize the window effortlessly while maintaining the window's aesthetic appearance.

Actual behavior

The resize area of the WPF window is too narrow, making it difficult to resize the window without precise cursor placement. Users often struggle to adjust the window size because the cursor needs to be exactly on the edge to initiate the resize action. This results in a frustrating user experience, as the limited resize area hampers the usability of the application.

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

ludelues commented 1 week ago

Nuget = ModernWpfUI

miloush commented 1 week ago

Have you tried setting Window.ResizeMode to CanResizeWithGrip? It should add a resizing area to the bottom right of the window.

himgoyalmicro commented 1 week ago

@ludelues does the above workaround resolves your issue?

ludelues commented 3 days ago

I want it to be resizable in all directions, and it currently works, but the area is too narrow.

ludelues commented 3 days ago

CanResizeWithGrip is an option that allows resizing only from the bottom-right corner. Did you not know that when you answered?

MichaeIDietrich commented 3 days ago

I think this question better belongs to https://github.com/Kinnara/ModernWpf repo, because window resizing seems to be affected by it.

As far as I can see using ui:WindowHelper.UseModernWindowStyle="True" overrides the default style for a Window and applies WindowChrome to the that window, which then handles the resizing regions for the window.

As a quick fix, could you try to wire up a Loaded event handler for the window and do something like this?

private void WindowOnLoaded(object? sender, EventArgs e)
{
    WindowChrome.GetWindowChrome((Window)sender).ResizeBorderThickness = new Thickness(10);
}
ludelues commented 2 days ago

WebView is in front of the WPF window, so it is not applied.

I hope Microsoft resolves this.

miloush commented 2 days ago

It would have helped if you included a repro project as requested.