[Problem/Bug]: When using an SVG format image as a menu item icon, it does not appear to be displayed.
What happened?
Discussed in https://github.com/MicrosoftEdge/WebView2Feedback/discussions/4543
Originally posted by Yookey May 8, 2024 Hello: I created a custom menu item using the following code, but it cannot display SVG format vector icons (bitmap icons can be displayed normally). I carefully read the development documentation, which clearly indicates that SVG format images can be used. did I make a mistake somewhere? doc: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2contextmenuitem.icon?view=webview2-dotnet-1.0.2194-prerelease#microsoft-web-webview2-core-corewebview2contextmenuitem-icon
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
128.0.2739.79
SDK Version
1.0.2739.15
Framework
Winforms
Operating System
Windows 11
OS Version
10.0.22631.4169
Repro steps
private void CoreWebView2_ContextMenuRequested(object sender, CoreWebView2ContextMenuRequestedEventArgs e)
{
e.MenuItems.Clear();
if (e.ContextMenuTarget.HasSelection && !string.IsNullOrEmpty(e.ContextMenuTarget.SelectionText.Trim('\n')))
{
var item = webViewer.CoreWebView2.Environment.CreateContextMenuItem("Copy Text", GetIcon(iconName), CoreWebView2ContextMenuItemKind.Command);
e.MenuItems.Add(item);
}
}
Stream GetIcon(string iconName)
{
if (string.IsNullOrWhiteSpace(iconName)) return null;
if (Icons.ContainsKey(iconName))
return Icons[iconName];
else
{
var bytes = UILayer.Properties.Resources.reply; // <--- this is a test image in SVG format
Stream stream = new MemoryStream(bytes) {
Position = 0
};
Icons.Add(iconName, stream);
return stream;
}
}
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response