wpf icon indicating copy to clipboard operation
wpf copied to clipboard

WPF + WEBVIEW

Open ludelues opened this issue 1 year ago • 8 comments

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 avatar Sep 26 '24 11:09 ludelues

Nuget = ModernWpfUI

ludelues avatar Sep 26 '24 11:09 ludelues

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

miloush avatar Sep 26 '24 12:09 miloush

@ludelues does the above workaround resolves your issue?

himgoyalmicro avatar Sep 27 '24 05:09 himgoyalmicro

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

ludelues avatar Oct 01 '24 04:10 ludelues

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

ludelues avatar Oct 01 '24 04:10 ludelues

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);
}

MichaeIDietrich avatar Oct 01 '24 08:10 MichaeIDietrich

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

I hope Microsoft resolves this.

ludelues avatar Oct 02 '24 13:10 ludelues

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

miloush avatar Oct 02 '24 13:10 miloush