Is it possible to simulate keystrokes in Silverlight (similar to SendKeys)? - silverlight

Is it possible to build a Silverlight application with an embedded on-screen keyboard that is context aware (e.g. on-screen keyboard appears only when a textbox is in focus).

Yes, but you need additional javascript that will show\hide the silverlight app.
For example: User focuses password textbox, javascript fires showing your app. Click on app's virtual keyboard raises javascript that edits textbox.
HTH

I was looking for the same thing, so I created a Virtual Input Keyboard that can attach to Textboxes and other controls - have a look here:
http://www.orktane.com/Blog/post/2009/11/09/Virtual-Input-Keyboard-Behaviours-for-Silverlight.aspx
Hope that helps, 5 months late though :)

Andrius Mudinas open sourced an excellent Silverlight on-screen keyboard:
http://www.mudinas.com/post/2009/07/10/Silverlight-Keyboard-Control.aspx
We've integrated this into our own Silverlight app. Remember to copy the keyboard styling from their App.xaml to your project's App.xaml.
You can wire into the KeyPressed event.

Related

How to make that WPF Virtual keyboard hides my controls

I'm developing a WPF application for tablet.
Since the framework 4.6.2, the virtual keyboard appears when a control gains focus.
I have a TextBox :
When this one gains focus so it becomes hidden :
Exists it native solution for correct this ?
Or must I manage a scroll viewer ?
Or show a dialog with my TextBox ?
I had the same issue with an application of my own, I ended using WPFTabTip which is open source and works like a charm. It is available through nugget also.
By using it you will need only one line of code:
TabTipAutomation.BindTo<TextBox>();
It automatically handles the visibility issue by moving the focused UIElement into view.
If you do not want to use the project you can see the source code and take what you need also.

How to implement the standard Windows Phone 7 ComboBox replacement UI

I'm trying to implement what seems to be the standard UI replacement for comboboxes in Windows Phone 7. This is the TextBox + Navigate to New Page with Listbox approach you can see in the settings page of the Emulator.
I got the following issues while trying to implement this approach, speficically related to the TextBox:
If I use a ReadOnly TextBox the text appears in light gray, which is not really what I want. I want the normal black font there.
If I don't use a ReadOnly TextBox the virtual phone keyboard will appear in some rare situtations, even when I handled the MouseEnter event. I can't consistently reproduce the situations when the keyboard appears.
Which is the best approach to implement this behaviour?
The Windows Phone Toolkit has a ListPicker that is quite flexible and easy to use.
Have you considered just using a TextBlock with an invisible button over the top? Or associate a gesture to take the tap event?
You could also check out Alex's implementation here of a picker box.
Implementing Picker Box functionality on WP7. - Alex Yakhnin's Blog

Wpf popups or modal windows as user entry screens?

I am building an application which has multiple user entry screens. I would like to know if there are advantages/disadvantages of using wpf popups rather than modal windows?
I am using mvvm-light.
I have noticed that popups are being used extensively in touch applications (eg iPad).
The issue is really one of Desktop vs. Web applications. Popups in Silverlight (or other touch apps) involve having only one real window to work with (the mobile surface, or the web browser). If you are writing a desktop app, then modal windows will probably match user expectations better as Popups cannot leave the parent window.
pop ups are nice but are very difficult to control. In our apps we are using adorners to be 'pop-up' editors - we have created a control that can hold any other control and display it in the adorner layer of the main window. This allows to do things such as having 1 control appear next to another yet still have the other control in use or we can grey out the background and force focus to the new control and not allow any other control to be used until the 'ok' button is pressed. If you Google for adorners in wpf you will find a lot of excellent articles.

Is there a ChildWindow equivalent on Windows Phone 7? How to do rich modal popups

I'm developing a phone app and need a modal dialog with some "rich" content - a few text boxes and a drop down. OK, not very rich but more than a MessageBox. :>
In regular Silverlight I know there's the ChildWindow control - but can't find the equivalent in Phone 7.
How have other folks done rich popup dialogs on the phone?
Thanks!
Silverlight actually has a control called a Popup. Here's the MSDN documentation.
It's incredibly simple to use (just set IsOpen to true to dispay) and quite effective. The only reason you might use a Panel with manual state control would be is you want precision control over animations etc.
Where I've seen people implement something like this they just have added a panel to the page and made this visible to act as a modal popup.
If you do this, be sure to handle use of the back button correctly.
Actually, there is ChildWindow on Windows Phone 7 in System.Windows.Controls library.
These are some examples:
http://www.c-sharpcorner.com/uploadfile/raj1979/how-to-implement-childwindow-in-windows-phone-7/
http://blog.deepwire.co.uk/?p=434
http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2011/06/how-to-create-childwindow-login-popup.html

Silverlight 3: How to implement Textblock copy/paste functionality?

Silverlight is awesome, most of my application users are giving positive feedback about silverlight. However some of the users are not able to live without copy/paste functionality. They are very much used to copy/paste functionality provided by HTML page out of the box.
How can I implement such a context menu as well as copy/paste functionality?
PS: Windows only solution is fine too.
Aside from using TextBox with IsReadOnly=true, you'll have a pretty hard time trying to simulate selection and copy/paste in a TextBlock. I would identify the areas they wish to copy/paste the most and use TextBox's there. You could even remove the border and make a transparent background and it should look nearly identical to adjacent TextBlock's.
If you do that then you will get the selection and copy functionality provided by TextBox and it works across browsers.
Otherwise you will need to go through the browser's DOM to put stuff on the clipboard and that will be a pain because of cross-browser concerns. Silverlight 4 adds a Clipboard API if you're able to start development with a beta version.
As Josh has answered, style a TextBox to look like a TextBlock. In terms of copy and paste:
Assuming the users aren't content with just CTRL+C, CTRL+X or CTRL+V - you can now access the clipboard in Silverlight 4:
string content = Clipboard.GetText();
Clipboard.SetText("hello world");
A context menu can be done in various ways, and in Silverlight 4 it is actually properly supported cross browser instead of just IE. You could do it with a Popup or a ChildWindow or just use one from the Vectorlight library:
This open source project on Codeplex contains a demo that does just that and much more:
http://sl4popupmenu.codeplex.com/

Resources