WPF - C# Put a label over a PictureBox (using windowsformhost)

184 Views Asked by At

I am currently developping an interface that shows multiple camera shot and the direct view of the camera.

What i need to do is put a label on a picturebox (picturebox that refresh camera live every frame).

My problem is that when the picturebox refresh, the label get under it.

Here's how my XAML code is made :

<Grid x:Name="GridCam4" Grid.Column="1" Grid.Row="1" Margin="0,0,24,0">
                
                    <WindowsFormsHost x:Name="DisplayWindow" Foreground="#FFA0A0A0" Background="#FFA0A0A0" Panel.ZIndex="2" Height="435" Width="678">
                        <forms:PictureBox x:Name="picturebox1" BackgroundImageLayout="None"/>
                    </WindowsFormsHost>
                
                <Label x:Name="LabelLive" Content="Live :" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="102" Width="206" FontSize="36" Panel.ZIndex="12" Foreground="White"/>
</Grid>

And there is my C# code :

private void onFrameEvent(object sender, EventArgs e)
    {
        uEye.Camera Camera = sender as uEye.Camera;

        Camera.Memory.GetLast(out s32MemID);
        
        //Display the image on the screen (Refresh the picturebox with last picture taken)

        Camera.Display.Render( DisplayHandle, uEye.Defines.DisplayRenderMode.FitToWindow);
         Camera.Memory.Unlock(s32MemID);

        
        this.Dispatcher.Invoke(
              new Action(() =>
              {
                  LabelLive.Content = "Live :";  //Trying to refresh the label to put it over  picturebox
              }),
              DispatcherPriority.ApplicationIdle);
    }

I really don't know what to do to deal with this...

I have also tried ZPanels but nothing worked at the moment.

Thanks for your help !

0

There are 0 best solutions below