Webcam video does not render again once I switch tabs

144 views Asked by At

I'm using the the wpf-mediakit library to render a video stream from a usb camera for my desktop application.

Tha XAML:

<TabItem>
    <Grid>
        <controls:MediaUriElement x:Name="mediaUriElement" Grid.Row="1"
                              DeeperColor="False"
                              Margin="4"
                              Stretch="Uniform"/>
        <controls:VideoCaptureElement x:Name="cameraCaptureElement" Grid.Row="1"
                                  EnableSampleGrabbing="False"
                                  DeeperColor="False"
                                  Margin="4"
                                  Stretch="Uniform"/>
    </Grid>
</TabItem>

And the code-behind:

public MainWindow()
        {
            InitializeComponent();            

            cameraCaptureElement.VideoCaptureDevice = MultimediaUtil.VideoInputDevices[0];
        }

The problem is, when I switch tabs and return to this tab item, the stream does not render at all. As far as I could tell, this is some Tab Virtualization problem, but I was out of ideas on how to solve this. Also, ideally, I would not want to re-initialize the stream every time as it takes a couple of seconds to do so.

0

There are 0 answers