Ok, now I solved it. I think the solution can be appreciated by others, so here it is:
It seems you cannot assign PhotoCamera as the source for the software-created VideoBrush, so I edited my xaml to contain
<Rectangle>
<Rectangle.Fill>
<VideoBrush x:Name="VB" />
</Rectangle.Fill>
</Rectangle>
This was followed by simpler code.
VB.SetSource(new PhotoCamera());
In addition, this code is contained in the OnOrientationChanged event, which appears several times, therefore is contained in
if (!processing)
{
processing = true;
VB.SetSource(new PhotoCamera());
var bw = new BackgroundWorker();
bw.DoWork += (object, sender) => {
Thread.Sleep(250);
processing = false;
}
}
the code runs smoothly.
source
share