简体   繁体   English

WPF Window中如何设置webview2的圆角半径

[英]How to set the corner radius of webview2 in WPF Window

In a Window of my WPF application, I have added a webview2 and trying to make its border rounded.在我的 WPF 应用程序的 Window 中,我添加了一个webview2并试图使其边框变圆。

<Window x:Class="Webview2Experiment.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:Webview2Experiment"
    xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="400"
    WindowStyle="None"
    AllowsTransparency="True"
    Background="Transparent">
<Border Background = "White"
        Opacity = ".01"
        Margin="0,0,0,0"
        Width="400"
        CornerRadius="22">
    <wv2:WebView2 Name = "webView2" 
                  Width="400"
                  Height="450"
                  />
</Border>

Setting the cornerRadius property of the Border did not help.设置BordercornerRadius属性没有帮助。 Though the Border was rounded, the webview content was visible around the sharp corners.虽然边框是圆形的,但 webview 的内容在尖角周围是可见的。

I also tried setting the cornerRadius in the parent Window and clipping the content within the Window and also in the Border.我还尝试在父 Window 中设置cornerRadius ,并在 Window 和边框中剪切内容。 Every time the container was rounded but the web content was visible around sharp edges.每次容器都是圆形的,但 web 的内容在锋利的边缘周围是可见的。

So, is it possible to achieve the desired effect from the WPF client-side, and how to do this?那么,WPF客户端是否可以达到预期的效果,如何实现呢?

Seems to be not supported for now.好像暂时不支持。 Maybe you can open a feature request pointing to this comment .也许您可以打开指向此评论的功能请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM