0
在我的WPF應用程序中,我在CefSharp Web瀏覽器中加載URL。當我給小鼠右擊,默認上下文菜單顯示如下圖像WPF - 在CefSharp鉻瀏覽器中右鍵單擊時刪除默認上下文菜單
我的XAML代碼是
<Window x:Class="StoneApp.WebviewWindow" WindowState="Maximized"
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:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
xmlns:local="clr-namespace:StoneApp"
mc:Ignorable="d"
Title="MyApp">
<DockPanel>
<Grid x:Name="mygrid">
<cefSharp:ChromiumWebBrowser x:Name="my_webview" IsBrowserInitializedChanged ="InitializeBrowser" Grid.Row="0" MouseRightButtonDown="Rightbtn_MouseDown"/>
</Grid>
</DockPanel>
</Window>
我xaml.cs代碼
public WebviewWindow(string webresponse)
{
InitializeComponent();
this.webresponse = webresponse;
}
private void InitializeBrowser(object sender, DependencyPropertyChangedEventArgs e)
{
my_webview.Load(webresponse);
}
private void Rightbtn_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.RightButton == MouseButtonState.Pressed)
{
e.Handled = false;
}
}
當我給rightclick我也無法調用'Rightbtn_MouseDown'函數。所以我的問題是我想刪除/隱藏默認的上下文菜單,當右鍵單擊瀏覽器視圖。你可以給我任何關於這個問題的幫助。提前致謝。