Monday, April 11, 2011

Making a WPF application retain focus at all times

Hello everyone,

I've got an issue with a WPF app I'm writing. The application needs to be able to keep focus at all times. The computer it's running on is a highly specialized machine with the only purpose of running this application.

There is no keyboard connected to the machine (it has a touch screen), so the only thing that can steal focus is windows own "needy windows", such as windows update etc.

How can I make it so that my app retains focus at all times? Is it possible to make the entire app modal?

EDIT:

Thank you both for your answers. I think I'll end up using Topsmost for now, but I'll definitely check out the source of babysmash as that application works exactly the way I want mine to, in regards to the way it handles focus.

From stackoverflow
  • Look at the source of BabySmash. It is specifically designed to keep focus even under quite bizar circumstances. (It is a program designed to run at full screen and let babys smash on a keyboard - so quite some focus went into capturing all kinds of weird keyboard combinations and alert messages).

  • I would use

    <Window ... Topmost="True">
    

    i xaml. But maybe this is not what you are looking for

0 comments:

Post a Comment