In order to create a screen shot, I am hiding a wpf window. The code looks like that.
Hide开发者_开发问答();
var fullScreenshot = _cropper.TakeFullScreenshot();
Show();
Sometimes the Application is not hidden when the screen shot is taken. How can I can I identify, that the window is completely hidden?
I don't know how the screenshot is taken but I suspect that the UI-Thread has not removed all the content and therefore the TakeFullScreenshot
sees rests of your app.
I would try to wait until your app has done all necessary ui-work and then trigger the TakeFullScreenshot
-operation.
Trigger the ScreenShot-Operation with the Dispatcher
:
Hide();
Dispatcher.BeginInvoke(new Action(delegate {
fullScreenshot = _cropper.TakeFullScreenshot();
Show();
}), System.Windows.Threading.DispatcherPriority.ContextIdle, null);
Currently I am trying out this solution:
public void Foo()
{
IsVisibleChanged += WhenVisibiltyChangend_TakeScreenshot_and_OpenCreateTicketDialog;
Hide();
}}
void WhenVisibiltyChangend(object sender, DependencyPropertyChangedEventArgs e)
{
if ((bool)e.NewValue == false) {
var fullScreenshot = _cropper.TakeFullScreenshot();
Show();
}
}
I hope this is the correct answer, but I have to do some additional tests.
精彩评论