1

I've added a WPF user control to a WinForms Form but I'm not able to receive events on my WPF control.

I've tried to subscribe the MouseEnter event but the event handler method is never called. I'm adding the WPF control with the Visual Studio (2010 Express edition) designer. I add an ElementHost and then associate my control to the host.

Here is a screenshot of the form:

enter image description here

The WPF control is an help ad below toolstrip. There is a link at the end of the control that, when added to the winform elementhost, won't receive any input events.

Here is the xaml code of the component:

<UserControl x:Class="Telbit.TeStudio.View.Forms.HelpAd"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="30" Width="500"
x:Name="HelpAdControl"
Background="#FFD3DCE6"
BorderBrush="#FFB9C4D2"
BorderThickness="0 0 0 1">
<Grid>
        <StackPanel Orientation="Horizontal">
        <Image Name="icnHelpAd"
           HorizontalAlignment="Center" VerticalAlignment="Center"
           Visibility="{Binding ElementName=HelpAdControl, Path=HasIcon}"/>
        <TextBlock Name="txtHelpType" Margin="5 0 0 0"
               Visibility="{Binding ElementName=HelpAdControl, Path=HasType}"
               Text="{Binding ElementName=HelpAdControl, Path=HelpType}"
               TextBlock.FontFamily="Verdana" TextBlock.FontSize="10" FontWeight="Bold" Foreground="#FF939FBB"
               VerticalAlignment="Center" />
        <TextBlock Name="txtHelpDescription" Margin="5 0 0 0"
               Visibility="{Binding ElementName=HelpAdControl, Path=HasDescription}"
               Text="{Binding ElementName=HelpAdControl, Path=HelpDescription}" 
               TextBlock.FontFamily="Verdana" TextBlock.FontSize="10" Foreground="#FF444444"
               VerticalAlignment="Center" />
        <TextBlock Name="lblHelpLink" VerticalAlignment="Center" Margin="5 0 0 0">
            <Hyperlink Name="lnkHelpLink" 
                       TextBlock.FontFamily="Verdana" TextBlock.FontSize="10" Foreground="#FF255BC8"
                       Click="lnkHelpLink_Click" NavigateUri="{Binding ElementName=HelpAdControl, Path=HelpKey}">
                <TextBlock Text="{Binding ElementName=HelpAdControl, Path=HelpLinkDescription}" />
            </Hyperlink>
        </TextBlock>
        <TextBlock Name="lblNextHelp" 
                   Margin="5 0 0 0" Width="16" VerticalAlignment="Center" HorizontalAlignment="Right" ToolTip="Next Help Tip" 
                   TextBlock.FontFamily="Verdana" TextBlock.FontSize="10">
            <Hyperlink Name="lnkNextHelp" Click="lnkNextHelp_Click" NavigateUri="www.mock.com">
                »
            </Hyperlink>
        </TextBlock>


    </StackPanel>
</Grid>

Just another note: the mouse cursor is not changed when the mouse is hover the link component. It seems to me that the events are not being send to WPF control.

Any idea of waht may be causing this problem?

jpsstavares
  • 3,303
  • 5
  • 25
  • 32

0 Answers0