Making a WPF application retain focus at all times - wpf

I've got an issue with a WPF application that I'm writing. The app 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.

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

Related

In WPF, only disable/hide minimize function, allow everything else

My WPF application has a number of "pop-up" dialogs. There's no real need to show them on the task bar. Problem is that by turning off "ShowInTaskBar", they can be minimized to what I think is a somewhat unconventional representation (just above the taskbar), and as such can be inadvertently pushed down in z-order behind the "parent" or other windows, thus seemingly disappearing, but still deactivating the parent while open. There's no real need to minimize them anyway (user might as well just close/cancel), so I think it would make sense to disable minimize functionality for the "pop-up" windows. What would be the most straightforward way to do that (still allow resize/maximize/restore)? As best I recall, this was no big deal in "old-fashioned" Win32/MFC/Winforms - either a checkbox setting to disable the minimize box or a simple tweak of the system menu.
One of the favoured solutions I've seen in a related Q&A was to make the window "NoResize", but I want most of them resizeable. Another answer was to customize the title bar... is that really necessary? Would it be possible/feasible/advisable to access and tweak the system menu in WPF? Any "gotchas" in doing so?

Is it possible in c# to show, hide, and manipulate the Windows 8 on-screen keyboard?

I am making a WPF application that is to be used on a kiosk with no hardware keyboard. Currently we are using a third party on-screen keyboard, but the Windows 8 version is a lot better and we are thinking of switching to it.
So my question is simply if it is possible to show/hide it as well as show a numeric only version using c#.
Thanks!
David
From this source:
There is no direct way to control the touch keyboard programmatically.
Requiring the user to set the focus rather than the program is a
deliberate design decision to prevent UI churn.
See Input Hosting Manager and the Touch Keyboard for more information
on how and why this works. The User-driven invocation section of that
document explains the specific behavior you are asking about.
But, once the user touches an input control, the soft keyboard will automatically be displayed (with no extra coding needed).
Finally, to address your question on a numeric-only version of a keyboard, you may propose a different keyboard layout using InputScope on a TextBox. The different input scopes are enumerated here, but one of them is "Number".
I've published a sample on how to trigger the touch keyboard in WPF applications when a user clicks into a Textbox, its here:
http://code.msdn.microsoft.com/Enabling-Windows-8-Touch-7fb4e6de
I've been working on this sample for many months and am glad to finally contribute it to our community. Please let me know if there are any questions, suggestions, problems, etc in the sample Q&A pane
Also note that while demonstrate how to "show" the keyboard, i'm not sure how to dismiss it programmatically at this point so its important to test any actual implementation to ensure its a good experience. For example some controls like Button will dismiss the keyboard when they get focus from a TextBox, but certain ones like Checkbox will not and I demonstrate that in my sample.

Windows 8 like modal dialog using WPF

I am working on a WPF-MVVM (.Net 4.0) application that has a Metro look (it just has a look, it is not a metro application.)
I need to show a windows 8 like message box that blocks the operations for the user before he rids that message box by clicking yes/no/cancel (or any button.).
I came across this otherwise great article and momentarily thought that I have found the solution. But this has its own drawback.It just stops the user from interacting with the controls behind by mouse clicks. The user can however use the tab key to get back to the buttons behind and click them (pressing enter).
A number of things are coming to my mind:
should I go for custom adorners and play with hitTestable property?
Or should I place a control and play with its visible property.
Before going for any approach I thought of putting forward my question to the wonderful community here if someone has done a similar thing in past and provide me some pointer/reference/approach.
Can someone suggest what is the way to achieve this? Please note I will be happy to use prism or any other open source if that solves the purpose but the window will have to be custom made.
Please excuse me if you find this too stupid a question. Please pardon my ignorance. Thanks for reading this.
I recently came across a similar problem, I resolved it using a DialogPresenter as explained there:
http://www.codeproject.com/Articles/36516/WPF-Modal-Dialog
I had to do a few tweaks there and there but overall it's working fine and I now have a nice way to display dialog boxes!
There is a better way of doing it
var dialog = new MessageDialog("Select Social network is already authorised!");
dialog.ShowAsync();

Touch screen operations for .NET windows application?

We are building a Windows application in .NET and one of its requirements is touch screen monitor. Other than that, it's a normal windows form based application. But except for making UI items little bigger for touch, I can't find anything I as a developer need to do for the requirement since touch screen is basically mouse operations. Am I missing something?
No, you are not missing anything. Do get the actual hardware hooked up so you can test it, "little bigger" is invariably underestimating the problem of fat fingers. Everything should work from a single click, right-clicks are horribly impractical, double-clicks are best avoided.
The only other thing you'll want to do is go into the Control Panel + Display applet and change the size of standard Windows UI elements. Pick a large window caption font if you want to allow the user to drag or close windows. Make the scrollbars at least twice as wide. And the menu and message box font. Go in the Mouse applet to increase double-click range and time if you want to support that.
If you do not need touch-specific event handling I think it's all you have to do. But touch means more than that and you may want to support it in a better way: http://archive.msdn.microsoft.com/WindowsTouch/Release/ProjectReleases.aspx?ReleaseId=2127

WPF: How to make a Google Chrome style GUI in WPF/MVVM?

I bet you guys know Google Chrome browser, yeah it comes from Chromium open-source projects, added some Google specific features.
I found the multi-tab GUI is quite attractive, especially the "drag-and-drop" feature for tabs and windows:
to "pull a tab" out to form a separate window, or
vice versa, to join a tab into a windows (that has a collection of tabs).
This would be quite helpful for designing some multi-process applications to achieve the stability, and a cool user experience, but ... how?
is it possible to do this in WPF?
or even one step more, is it possible to do this in MVVM?
Yeah, technically, everything is possible, but I can't see an easy pattern to do this
for WPF, how to handle such specific "crossing window" mouse interaction?
for MVVM, hmmm, will this be too challenging for MVVM?
cheers
maybe you should have a look at these libs/frameworks:
http://fabtab.codeplex.com/
http://avalondock.codeplex.com/
http://fluidkit.codeplex.com/
Its definitely possible. I've recreated the chrome tab look in the past with MVVM, complete with drag and drop, and I know another guy who created a tabbed application that lets you "pull away" tabs into a new window of its own. I believe it was all one application with multiple windows, so all open windows were part of the same application even if they show up separately in the task bar.
I'm not sure if I have his source code or not, I'd have to go digging for it.

Resources