In WPF if I have a item that currently has focus, if I select a menu item, after executing the menu item focus is returned to the item that had focus. I'm trying to replicate that with a WebView and not having any luck.
In my example, if I give focus to the HTML textarea and then select the Test menu item the textarea loses focus. If I replace the HTML content with standard XAML the focus is returned correctly. It's easy to see this behavior
1. click in WPF textbox
2. select menu item
3. type - content will change in textbox
4. click in HTML textarea
5. select menu item
6. type - content does not go in textarea
My example is
XAML
Code: XML
<Window
x:Class="WpfApp6.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:eo="http://schemas.essentialobjects.com/wpf/"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<DockPanel LastChildFill="True">
<Menu DockPanel.Dock="Top">
<MenuItem Header="Tools">
<MenuItem Header="Test"></MenuItem>
</MenuItem>
</Menu>
<DockPanel LastChildFill="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Canvas>
<TextBox Width="200" Height="100"></TextBox>
</Canvas>
<eo:WebControl Grid.Row="1" x:Name="eob"/>
</Grid>
</DockPanel>
</DockPanel>
</Window>
c#
Code: C#
using EO.WebBrowser;
using System.Windows;
namespace WpfApp6
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
eob.WebView = new WebView
{
Url = "file:///...test.html"
};
}
}
}
HTML
Code: HTML/ASPX
<html>
<textarea id="txt" rows="4" cols="50">
At w3schools.com you will learn how to make a website. They offer free tutorials in all web development technologies.
</textarea>
</html>