The Elementhost and the Popup

383 views Asked by At

I got a problem with the Windows.Forms.ElementHost. Within the host I placed a WPF UserControl, in which I got a Popup.

Some Code:

<UserControl
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       mc:Ignorable="d" 
       d:DesignHeight="300" d:DesignWidth="380">
    <Grid>
        <Popup x:Name="TestPopup"
              IsOpen="{Binding PopupVisible,UpdateSourceTrigger=PropertyChanged}" 
              Placement="Center" 
              StaysOpen="False" Width="200" Height="50">
            <Grid>
                <TextBox/>
            </Grid>
        </Popup>
        <Button Click="Button_Click" />
    </Grid>
</UserControl>

So in this example all I got is a ElementHost, a UserControl and a Popup (and a ViewModel in which the IsOpen variable PopUpVisible for the popup is implemented).

Now I got two Buttons... one in my UserControl and one in my WindowsForm with the ElementHost.

Each of the two buttons sets the IsOpen variable PopUpVisible to true. So if I push the button´s the same popup is shown. Until this point everything works fantastic.

Now I got a textbox in my popup... I click in this textbox and begin tipping some random stuff... If I push the button in my wpf usercontrol this works! But if I push the button in my WindowsForm things start to get weird! I got focus and everything on my textbox but the textbox won´t get any of my keyboard tipping. I checked and doublechecked it... I definitely got my "Keyboard Focus" on the textbox!

A bit stuck here... someone has an idea?

Kind Regards.

0

There are 0 answers