Virtual Input Keyboard & Behaviours for Silverlight

Posted by Rishi on 09-Nov-09 9:04 AM - Comments (65)

You would already know this, but in Silverlight when in full-screen mode keyboard input is by design constrained to a limited set of keys - this often takes an end-user by surprise and leaves them with a perception than it's an application problem. To overcome this Silverlight limitation I've created a Virtual Input Keyboard and accompanying behaviours, that allows you to attach an on-screen keyboard to any receptive UI control.

VirtualInputKeyboard

View the demo app here.

The Input Keyboard

It is important to appreciate that the Silverlight Keyboard presented here is an Input Keyboard, which is different from a general purpose Virtual Keyboard found in most Operating Systems. The input keyboard is specifically only made visible on-screen when directly editing/inputting to an attached UI control (e.g. a TextBox), when not editing/inputting it is automatically hidden from view - this is very much like in mobile phones. So for example with the PasswordBox shown above the Input Keyboard will be made visible when the PasswordBox has focus, and in the "focus" state it allows you to "key-in" characters but anytime the PasswordBox looses the focus the keyboard also vanishes.

 K for Keyboard

Symbols Keys

Key Features

  • All character-keys feature iPhone'que callouts/popouts when pressed
  • A symbols mode (bottom right key) features most of the commonly used symbol and non-alphabetic characters (shown above) - however currently there is no support for customizing or appending custom symbols
  • There is a sticky shift-key (bottom left) that allows for capitalized alphabets
  • The keyboard also allows for a Title, above it is set to "User Password"
  • The keyboard is collapsable, see the arrow key show above (top right)
  • The keyboard is dragable, and is not constrained to its parent's bounds
  • The keyboard is based on the Popup Primitive in Silverlight, so it is not effected by z-index based layering
  • A single keyboard control instance can be registered and used throughout the application as the default keyboard
  • You avail the keyboard by attaching behaviours to UI controls, included are behaviours for attaching to a Textbox or a PasswordBox control
  • You can create custom behaviours to consume the Keyboard with other kinds of UI controls such as a Grid or ListBox (I will post separately about how to do this)
  • The behaviours also allow you to configure as to if the Keyboard is only available when in full-screen mode (the default setting)

Behaviours

Like I mentioned included are three behaviours based on the Blend SDK, which allow you the configure and attach the Keyboard with various UI controls.

ApplicationInputKeyboardBehavior

You put this behaviour onto an Input Keyboard, and it makes it the default application-wide keyboard for use by one or more UI controls. Without this, you'll need to specify onto each attached control the keyboard you want to use it. Further, to make life easy it has no configurable settings, so simply drag and drop this onto an Input Keyboard.

TextBoxInputKeyboardBehavior TextBoxInputKeyboardBehavior

This behaviour is applied onto a TextBox, and it in turn attaches a Keyboard onto it. Using this behaviours is very simple, it has three properties - one to specify the Title that is shown atop the Keyboard (note its use is optional). The second property, takes in the Target Keyboard name, as shown in the screenshot on your right. However, if you wanted to use the default application wide keyboard (as described above), then you leave this empty and it will resolve it automatically. Lastly, the VisibleInNonFullScreenMode property, allows the Keyboard to be visible when not in full-screen mode. Note again, the default behaviour will only show the keyboard when in full-screen mode, so turn this on if you want it available independent of the full-screen mode.

PasswordBoxInputKeyboardBehavior

As the name suggests this behaviour is applicable to PasswordBox controls, and the use API is identical to the TextBoxInputKeyboardBehaviour. However, the use-semantics are quite different - the TextBox keyboard behaviour can identify and use text-selection and cursor position information, and therefore the interaction with the Input Keyboard fully mimics the use-semantics we are accustomed too with a physical keyboard and mouse. Now, the PasswordBox control doesn't expose text-selection or cursor position information, which leads to somewhat counter-intuitive use interaction. For example, if you've partially selected some part of the password text and press a key with your physical keyboard it would overwrite the selection with the keyed character. However, with the Virtual Input Keyboard you can only append any keyed character to the end of the password string, because we are not party to selection or cursor-position information with the PasswordBox control. Also the automation API in Silverlight suffers from the same information deficiencies, which is why I've forgone its use.

Future Enhancements

Since this is just the first shot at this, there are plenty of possible enhancements. Some of the ones I am considering are:

  • Customizable key-sets, using predefined profiles - kind of like how iPhone offers a different key-set for entering Urls
  • An optional default action key, like one to trigger a "Google" - this is also akin to iPhones
  • Key press sounds option
  • Configurable relative positioning of Keyboard to any attached UI control
  • A numeric-pad version of the Input Keyboard, that only offers numeral characters
  • Templat'able Keyboard and Keys UI
  • A sharper/better default skin

If you have any other suggestions or ideas, do let me know.

You can download the Input Keyboard dll (16 kb) from the Expression Gallery Site,
and again you can view the demo app here.

UPDATE (17-Dec-09):

The following are two classes that allow you to attach the Keyboard to an AutoCompleteBox Control (found in Silverlight Toolkit). However do note that the AutoCompleteBox does not expose selection information so the keys are added and removed from the end of the text-string only - which unfortunately is not all that intuitive.

   1: // Keyboard Input Handler for AutoCompleteBox
   2: public class AutoCompleteBoxInputHandler : IInputKeyboardHandler
   3: {
   4:     
   5:     readonly AutoCompleteBox _autoCompleteBox;
   6:     
   7:     public event EventHandler InputKeyboardAttached;
   8:     public event EventHandler InputKeyboardDetached;
   9:  
  10:     public AutoCompleteBoxInputHandler(AutoCompleteBox autoCompleteBox)
  11:     {
  12:         if (autoCompleteBox == null) throw new ArgumentNullException("autoCompleteBox");
  13:         _autoCompleteBox = autoCompleteBox;
  14:     }
  15:     
  16: #region IKeyboardHandler Implementation
  17:     
  18:     public void KeyboadAttached() 
  19:     { 
  20:         if (InputKeyboardAttached != null) 
  21:             InputKeyboardAttached(this, EventArgs.Empty);
  22:     }
  23:         
  24:     public void KeyboardDetached() 
  25:     { 
  26:         if (InputKeyboardDetached != null) 
  27:             InputKeyboardDetached(this, EventArgs.Empty);            
  28:     }
  29:     
  30:     public void CharacterKeyed(Char character)
  31:     {
  32:         // we append to the end the added character, also notice there is no max length on auto-complete
  33:         _autoCompleteBox.Text = _autoCompleteBox.Text + character.ToString();
  34:     }
  35:     
  36:     public void BackspaceKeyed()
  37:     {
  38:         // we remove one letter from the end
  39:         var _existingText = _autoCompleteBox.Text;
  40:            if (_existingText.Length > 0)
  41:             _autoCompleteBox.Text = _existingText.Substring(0, _existingText.Length - 1);    
  42:     }
  43:     
  44: #endregion
  45:     
  46: }
  47:  
  48: // Behaviour Class to Attach to AutoCompleteBox
  49: public class AutoCompleteBoxKeyboardBehavior : InputKeyboardBehaviorBase<AutoCompleteBox>
  50: {
  51:     
  52: #region Override
  53:  
  54:     protected override IInputKeyboardHandler ResolveKeyboardHandler()
  55:     {
  56:         return new AutoCompleteBoxInputHandler(this.AssociatedObject);
  57:     }
  58:     
  59:     protected override void OnAttached()
  60:     {
  61:         base.OnAttached();
  62:         
  63:         // we attach to the textbox
  64:         AssociatedObject.GotFocus += new System.Windows.RoutedEventHandler(AssociatedObject_GotFocus);
  65:         AssociatedObject.LostFocus += new System.Windows.RoutedEventHandler(AssociatedObject_LostFocus);
  66:     }
  67:     
  68:     protected override void OnDetaching()
  69:     {
  70:         base.OnDetaching();
  71:         
  72:         // detach the handlers
  73:         AssociatedObject.GotFocus -= new System.Windows.RoutedEventHandler(AssociatedObject_GotFocus);
  74:         AssociatedObject.LostFocus -= new System.Windows.RoutedEventHandler(AssociatedObject_LostFocus);
  75:     }
  76:  
  77: #endregion
  78:  
  79: #region Handler
  80:  
  81:     void AssociatedObject_GotFocus(object sender, RoutedEventArgs e)
  82:     {
  83:         base.AttachToKeyboard();
  84:     }
  85:     
  86:     void AssociatedObject_LostFocus(object sender, RoutedEventArgs e)
  87:     {
  88:         base.DetachFromKeyboard();
  89:     }
  90:     
  91: #endregion
  92:     
  93: }

Also remember, you can create IInputKeyboardHandler implementation along with a matching Behavior for other types of input controls you require.

UPDATE (24-Apr-10):

Released Version 1.5 for Silverlight 4 - download from http://slik.codeplex.com
Also includes demo app's source code - which is also updated to SL 4.

Note, this release is build against System.Windows.Interactivity.dll from Blend 4 RC

Comments

trackback
DotNetShoutout
on 27-Sep-09 11:33 AM
Virtual Input Keyboard & Behaviours for Silverlight

Thank you for submitting this cool story - Trackback from DotNetShoutout

trackback
DotNetKicks.com
on 27-Sep-09 11:36 AM
Virtual Input Keyboard

You've been kicked (a good thing) - Trackback from DotNetKicks.com

pingback
vincenthomedev.wordpress.com
on 30-Sep-09 10:08 PM
Pingback from vincenthomedev.wordpress.com

Full-screen Mode Virtual Input Keyboard for Silverlight « Vincent Leung's .NET Tech Clips

pingback
stevepietrek.com
on 01-Oct-09 11:08 AM
Pingback from stevepietrek.com

Links (11/12/2009) « Steve Pietrek – Everything SharePoint

veer
veer India
on 06-Oct-09 2:27 PM
HI,

How to use Orktane.Keyboard.dll, i refrenced it in the project, when i uses any behaviour, application raises an error. what does Target keyboard proerty is for ? can you upload a sample project solution.

Shirley
Shirley United States
on 09-Oct-09 8:55 PM
I was wondering if it was possible to resize the width and height of the keyboard? I tried to set the properties on it but it won't budge. Is there a special property?

Rishi
Rishi
on 09-Oct-09 9:45 PM
@Shirley, sorry the width and height are fixed and since the keyboard is setup as a popup, setting the width/height of the host control wouldn't effect it. However, I am sure about this, but you might be able to scale transform the keyboard by applying it to the host control.

Hope that helps.

Kinlars
Kinlars Norway
on 29-Oct-09 8:50 AM
It doesn't seem to work in anything else than a UserControl. It won't work in a navigation page, or SilverlightFX windows.

Rishi
Rishi
on 29-Oct-09 4:02 PM
@Kinlars, I hope you do know that Navigation Pages and Windows both maintain their own element naming scopes. So if you are referring to a Keyboard instance (by name) outside their scope it wouldn't work. In such a case you need to use ApplicationInputKeyboardBehavior onto the Keyboard and the Keyboard should be placed in the RootVisual (or elsewhere where it will be available for the lifetime of the app). Once an application-wide Keyboard is specified, then also don't specify the Target Keyboard on the TextBoxInputKeyboardBehavior or PasswordInputKeyboardBehavior as it will pick up the app-wide one. That should work, if not then you'll need to show me the specific code-example where it doesn't.

Antonio Dias
Antonio Dias Portugal
on 07-Nov-09 10:18 PM
First, congrats! Very nice control and i got it working very well.
Second, i'd really like to request some changes:
- Could you add a close/hide button to the control instead of only the "minimize"?
- An "Return" key would also be a nice addition
- The numeric only would be a really nice thing ;)

If you don't have time, i could implement some of this changes and send it to you!

Thanks

Antonio Dias
Antonio Dias Portugal
on 07-Nov-09 10:38 PM
By the way, i'm using an AutoCompleteBox from the Silverlight Toolkit. Any chance that you could add support for it?

Thanks

Rishi
Rishi
on 09-Nov-09 1:19 AM
@Antonio thanks. Firstly, about the changes I am not in favor of the closing/hiding the keyboard thing as once closed one would have to de-focus from the input control and then re-focus again to show up. I want the keyboard to be automatically availed kinda like in smartphones.

As for the Return key, I should have added it to support multi-line text input. However, what I'll do is update the control to support custom "key-set" profiles and put it on Codeplex - from where you can implement and submit changes. I've already got requests for non-English characters so that would also be possible there. In the meantime, I've added code to allow attaching to AutoCompleteBox control, hope that helps.

Antonio Dias
Antonio Dias Portugal
on 09-Nov-09 12:33 PM
Thank you for the quick reply.

I understand the problem with the close button, i asked because in the application i'm building there's a "Page" that only has a TextBox and so to hide the keyboard i have to press the Tab key on my real keyboard to de-focus the TextBox but the real keyboard might not be present (touch-screen interface). Unless i'm missing something..

Rishi
Rishi
on 09-Nov-09 11:55 PM
Well a simple solution would be to de-focus the text-box when IsCollapsed property of the InputKeyboard is set to true - see ValueTriggers in nRoute.Toolkit(.) But, just so that you can customize exactly to your needs, I'll send you the code to your given mail address. Hope that helps.

rlodina
rlodina Romania
on 02-Dec-09 6:15 AM
Hi Rishi,

The on-line demo return error:
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; InfoPath.2; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Wed, 6 Jan 2010 07:14:21 UTC


Message: Unhandled Error in Silverlight Application
Code: 2103    
Category: InitializeError      
Message: Invalid or malformed application: Check manifest    

Line: 53
Char: 13
Code: 0
URI: http://www.orktane.com/Labs/InputKeyboard/


Thank you

Rishi
Rishi
on 02-Dec-09 2:18 PM
@Rlodina, thanks for that tip - don't know what happened, but I've just updated it n' it seems to working fine now. Cheers.

Carlos Guevara
Carlos Guevara Panama
on 31-Dec-09 2:19 PM
Hello.  This is great work, congratulations.

I see that you are thinking about putting this wonderful keyboard up on codeplex, any idea when you might do that with the enhancements (skinning, etc.)??

My main problem with the keyboard was addressed recently in a post, because using the keyboard inside a PAGE (for navigation purposes) gives error in the PARSER when you add properties like TargetKeyboard or try to set it to be visible when non-full screen.  Using the applicationKeyboard behavior works, but it looks like it limits me to use the keyboard in ONE position for the whole application, but I can't tell if you can change the position (so that it does not cover other controls in certain windows, etc.).

Can you suggest a solution for my problem??? Thanks and again congratulations on an amazing control!

mundl
mundl Switzerland
on 03-Jan-10 5:44 AM
great work...
do you work on future enhancements?
or do you plan to publish the code?
so i can work for myself on future enhancements and realize my additional ideas.
    

Rishi
Rishi
on 05-Jan-10 10:23 PM
@Carlos, I am looking to do it within the month, I've created a Codeplex project called SLIK (stands for Silverlight Input Keyboard) and hope to get it started there. Now, about the moving thing, I'll check on it and come back to you. Plus the problem with navigation pages is not related to the Keyboard control but the naming scope of objects in Silverlight - a navigation page has its own naming scope.

@Mundl Like I said I'm putting it up on Codeplex, I wanna do some ground work first and then open it up. Further, I wanna provide multilingual support, so I need people from various language-speaking backgrounds if possible. If you are keen to help, then provide me with your Codeplex handle and I can add you to the project.

Cheers.

Rick
Rick United States
on 11-Jan-10 12:29 AM
Hey great job!! Very Awesome.
I"m just getting my feet wet with silverlight. I ran into a little issues on the install. I installed the behavior etc. but on the build I'm getting a error that reads - TextBoxInputBehavior does not exist in xml namespace-

Any thoughts?

Thanks

Rishi
Rishi
on 12-Jan-10 5:58 AM
@Rick, thanks - I can only speculate on cause of the error but I suppose you need to declare the xml namespaces for the keyboard and its behaviors in your xaml file, so something like should do:

<UserControl ..
  xmlns:Orktane_Keyboard="clr-namespace:Orktane.Keyboard;assembly=Orktane.Keyboard"
  xmlns:Orktane_Behavior="clr-namespace:Orktane.Keyboard.Behaviors;assembly=Orktane.Keyboard">
...
</UserControl>

I'll upload a sample project so you can have a look at it. Cheers.

HS
HS United States
on 21-Jan-10 12:36 AM
Hi Very Impressive work. I am not sure about using this code for my work. Could you please clarify, could anyone use this dll in his/her project?

Rishi
Rishi
on 21-Jan-10 6:28 AM
@HS, yes you canT use it in your code - it is released under the Creative Commons license. Though remember currently only a dll version is available, I'm working to put the code on Codeplex soon. Cheers.

Alex
Alex France
on 23-Jan-10 5:11 AM
Great control!
So I just have a question, maybe stupid...
How can I set the location of the keyboard on my page?
cheers

Alex
Alex France
on 24-Jan-10 8:19 PM
I thank the control was like a popup and that you can set the position via parameters but it's no the case.
I solved my problem by adding the keyboard in a user control for set the position easily.
Thank Wink

cheers

Gaston Touron
Gaston Touron Uruguay
on 06-Feb-10 7:15 PM
Hi, I am trying to use the dll but I am getting an PARSER error when I tried to use it, when using any of the properties, any clue?

Regards
Gaston

Gaston Touron
Gaston Touron Uruguay
on 07-Feb-10 12:41 AM
My mistake, I post a question without read enough, my real problem it is with TextBoxInputBehavior, when I use the properties application crashes. I have read (but not understand) some things about naming scopes and this kind of stuff. Could you clarify that?
I have an application behavior and textinputbehavior, everything working inside an usercontrol, if I add properties to textinputbehavior app crashes.
Regards
Gaston

Rishi
Rishi
on 09-Feb-10 1:41 PM
@Gaston, let me start with naming-scopes, it is really a very simple concept. Lets say you have two user-controls and in each of them you put in a button named "SaveButton", then you take a third user-control and put in it instances of the first-two user-controls onto it. Now, if you look at from the perspective of the VisualTree there are two elements named "SaveButton", but that is not allowed because it becomes ambiguous - yet it still works, and if you had tied logic to the two buttons they would still function. It works because, the UserControls are like enveloping containers within which the residing elements' names are scoped - to give you an analogy, think about mailing to address in Toronto. Now, there is a Toronto city in Canada but there is also one is US too, and so you mail will get delivered because they exist with the same name in the scope of a country. Hope that makes sense.

Now the name-scope issue with the Keyboard thing is that unless you have the Keyboard Control within the same name scope as the Text control it won't work. To remedy this you can apply the "ApplicationInputKeyboardBehavior" on any one instance of the Keyboard control and have it available application-wide (no matter the name-scope), and then with your "TextBoxInputKeyboardBehavior" you don't specify the keyboard handler name, it would automatically pick up the application-wide designated keyboard control and use it. The same applies to the Password control too.

If you now understand this set-of-designed behavior, hopefully your crashes should go away. Cheers.

ralf
ralf Germany
on 07-Mar-10 5:22 AM
Hi Rishi,

I want to add the "Interaction.Behaviors" inside a DataGrid in a Template like:

        <dataLaughingataGridTemplateColumn Header="Name"  Width="490">
          <dataLaughingataGridTemplateColumn.CellTemplate>
            <DataTemplate>
              <TextBlock Text="{Binding Name}" Margin="4" FontSize="26"/>
            </DataTemplate>
          </dataLaughingataGridTemplateColumn.CellTemplate>
          <dataLaughingataGridTemplateColumn.CellEditingTemplate>
            <DataTemplate>
              <TextBox Text="{Binding Name}" Margin="4" FontSize="26">
                <i:Interaction.Behaviors>
                  <Orktane_Keyboard_Behaviors:TextBoxInputKeyboardBehavior KeyboardTitle="Text" TargetKeyboardName="inputKeyboard" VisibleInNonFullScreenMode="True"/>
                </i:Interaction.Behaviors>
              </TextBox>
            </DataTemplate>
          </dataLaughingataGridTemplateColumn.CellEditingTemplate>
        </dataLaughingataGridTemplateColumn>

but it did not work. I get this error message:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB0.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.2; MS-RTC EA 2)
Timestamp: Mon, 22 Mar 2010 20:21:29 UTC


Message: Unhandled Error in Silverlight Application AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 3 Position: 150]   at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
   at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
   at MS.Internal.XcpImports.DataTemplate_LoadContent(DataTemplate template)
   at System.Windows.DataTemplate.LoadContent()
   at System.Windows.Controls.DataGridTemplateColumn.GenerateEditingElement(DataGridCell cell, Object dataItem)
   at System.Windows.Controls.DataGridColumn.GenerateEditingElementInternal(DataGridCell cell, Object dataItem)
   at System.Windows.Controls.DataGrid.PopulateCellContent(Boolean isCellEdited, DataGridColumn dataGridColumn, DataGridRow dataGridRow, DataGridCell dataGridCell)
   at System.Windows.Controls.DataGrid.BeginCellEdit(RoutedEventArgs editingEventArgs)
   at System.Windows.Controls.DataGrid.UpdateStateOnMouseLeftButtonDown(MouseButtonEventArgs mouseButtonEventArgs, Int32 columnIndex, Int32 slot, Boolean allowEdit)
   at System.Windows.Controls.DataGridCell.DataGridCell_MouseLeftButtonDown(Object sender, MouseButtonEventArgs e)
   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Line: 1
Char: 1
Code: 0
URI: http://localhost:52214/Silverlight.js

What is my mistake?


Rishi
Rishi
on 09-Mar-10 6:09 AM
@Ralf, off the top of my head I would say because a data-template is like a static resource, it does not have access to an "instanced" declaration of an element. Now, another likely cause could be the name-scope thing, since templated things are scoped within the themselves (to allow named-references), it might not have access to the "inputKeyboard" element - so try using the ApplicationInputKeyboard behavior and omit the TargetKeyboardName from the TextBoxInputKeyboard behavior. BTW, wonderful job with those smilies.

Junaid
Junaid United States
on 19-Apr-10 8:02 PM
Hi

i want to use the virtual keyboard in my course project is there is any way to customize the keyboard or change the background color theme .


Regards
Junaid

Rishi
Rishi
on 20-Apr-10 9:55 AM
@Junaid currently there is no direct way to do it, though you might be able to do it by probing the Visual-Tree. Also, since I'm now done with a new release of nRoute, I'll try to update this project soon.

Junaid
Junaid United States
on 20-Apr-10 7:52 PM
Hi Rishi

Thanks for  reply & please update the project as soon as possible.

Regards
Juanid



Sean
Sean United Kingdom
on 23-Apr-10 6:04 AM
Hi

Great control and I would really like to use it. Do you have an example application? I cant seem to attach the behaviors.

I am using Silverlight 4, would this be a problem?

Thank you
Sean

Helmut
Helmut Germany
on 23-Apr-10 11:52 AM
I'm looking forward to a customizable keyboard for my application Smile

Rishi
Rishi
on 24-Apr-10 6:02 AM
@Sean I think it might not be compatible because of System.Windows.Interactivity.dll - there is a new version out with Blend 4 RC. So I've put out a new release on Codeplex (http://slik.codeplex.com/) that targets Silverlight 4 along with the new interactive library. It also includes the source of the demo app shown here. Hope that helps.

Rishi
Rishi
on 24-Apr-10 6:05 AM
@Helmut I'm looking into the new version. I'm actually thinking about having a similar API to the SIP library in WP7 but with customizable templates.

Sean
Sean United Kingdom
on 26-Apr-10 3:27 AM
Thank you Smile

trackback
Yeejie's Blog
on 26-Apr-10 9:07 PM
Silverlight Soft Keyboard

Silverlight Soft Keyboard

ralf
ralf Germany
on 11-May-10 12:43 AM
@Richi

I implement your Keyboard in a ChildWindow. But the attached Behavior to a TextBox inside the ChildWindow give follow Error:

{System.Windows.Markup.XamlParseException: Das Hinzufügen eines Werts zur Sammlung vom Typ 'System.Windows.Interactivity.BehaviorCollection' hat eine Ausnahme ausgelöst. [Line: 22 Position: 55] ---> System.InvalidOperationException: Application-wide or Specified ('virtualKeyboard') Input Keyboard could be resolved for use.
   bei Orktane.Keyboard.Behaviors.InputKeyboardBehaviorBase`1.ResolveKeyboard()
   bei Orktane.Keyboard.Behaviors.InputKeyboardBehaviorBase`1.OnAttached()
   bei Orktane.Keyboard.Behaviors.TextBoxInputKeyboardBehavior.OnAttached()
   bei System.Windows.Interactivity.Behavior.Attach(DependencyObject dependencyObject)
   bei System.Windows.Interactivity.BehaviorCollection.ItemAdded(Behavior item)
   bei System.Windows.Interactivity.AttachableCollection`1.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   bei System.Windows.DependencyObjectCollection`1.TryCollectionChanged(NotifyCollectionChangedEventArgs e)
   bei System.Windows.DependencyObjectCollection`1.System.Collections.IList.Add(Object value)
   bei MS.Internal.XamlManagedRuntimeRPInvokes.Add(XamlQualifiedObject& qoCollection, XamlPropertyToken inCollectionProperty, XamlQualifiedObject& inValue)
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   bei aaX1.Reservations.Silverlight.BusinessApplication.Views.Note.InitializeComponent()
   bei aaX1.Reservations.Silverlight.BusinessApplication.Views.Note..ctor()}


{System.InvalidOperationException: Application-wide or Specified ('virtualKeyboard') Input Keyboard could be resolved for use.
   bei Orktane.Keyboard.Behaviors.InputKeyboardBehaviorBase`1.ResolveKeyboard()
   bei Orktane.Keyboard.Behaviors.InputKeyboardBehaviorBase`1.OnAttached()
   bei Orktane.Keyboard.Behaviors.TextBoxInputKeyboardBehavior.OnAttached()
   bei System.Windows.Interactivity.Behavior.Attach(DependencyObject dependencyObject)
   bei System.Windows.Interactivity.BehaviorCollection.ItemAdded(Behavior item)
   bei System.Windows.Interactivity.AttachableCollection`1.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   bei System.Windows.DependencyObjectCollection`1.TryCollectionChanged(NotifyCollectionChangedEventArgs e)
   bei System.Windows.DependencyObjectCollection`1.System.Collections.IList.Add(Object value)
   bei MS.Internal.XamlManagedRuntimeRPInvokes.Add(XamlQualifiedObject& qoCollection, XamlPropertyToken inCollectionProperty, XamlQualifiedObject& inValue)}

Do you have an idea how I can solve this problem??

Regards, ralf

Rishi
Rishi
on 11-May-10 1:09 AM
@ralf, the problem is simply that the behavior cannot find the Input Keyboard - either because the specified keyboard is not in the name-scope of the Child Window (see my comment about it above) or you have not specified an application-wide keyboard if you intended to use one (you specify it using ApplicationInputKeyboard behavior).

So the solution is either bring a keyboard control instance in the ChildWindow's visual tree/name-scope, or specify an application-wide keyboard. Cheers.

Rishi

ralf
ralf Germany
on 11-May-10 1:50 AM
@Rishi, I do not find my error?? My ChildWindow looks like:

<controls:ChildWindow
           xmlns="schemas.microsoft.com/.../presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
           xmlns:Orktane_Keyboard="clr-namespace:Orktane.Keyboard;assembly=Orktane.Keyboard"
           xmlns:Orktane_Behavior="clr-namespace:Orktane.Keyboard.Behaviors;assembly=Orktane.Keyboard"
           xmlns:d="schemas.microsoft.com/expression/blend/2008" xmlns:mc="schemas.openxmlformats.org/.../2006" xmlns:ei="schemas.microsoft.com/.../interactions" mc:Ignorable="d" x:Class="aaX1.Reservations.Silverlight.BusinessApplication.Views.Note"
           Width="400" Height="300"
           Title="Note">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" d:IsLocked="True" />
        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
        <TextBox x:Name="Note_TextBox1" Height="203" HorizontalAlignment="Left" Margin="12,12,0,0" VerticalAlignment="Top" Width="354" TextWrapping="Wrap" >
          <i:Interaction.Behaviors>
            <Orktane_Behavior:TextBoxInputKeyboardBehavior VisibleInNonFullScreenMode="True" TargetKeyboardName="virtualKeyboard"/>
          </i:Interaction.Behaviors>
        </TextBox>
        <Orktane_Keyboard:InputKeyboard x:Name="virtualKeyboard" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,-247,880,0">
            <i:Interaction.Behaviors>
              <Orktane_Behavior:ApplicationInputKeyboardBehavior/>
            </i:Interaction.Behaviors>
        </Orktane_Keyboard:InputKeyboard>

    </Grid>
</controls:ChildWindow>

How implement a application-wide Keybord??

Regards, ralf

Rishi
Rishi
on 11-May-10 3:23 AM
@ralf, found the problem and the solution. The problem is that a ChildWindow is not part of the Application RootVisual's VisualTree - which meant that we can only look for elements by name after the ChildWindow's VisualTree is itself initialized. And so as a solution, I've now put in place a check to wait till the VisualTree of the ChildWindow is loaded, and then only we try n' resolve the Keyboard.

Give me a little while n' I'll push the updates onto Codeplex.
Rishi

ralf
ralf Germany
on 11-May-10 3:47 AM
@Rishi, you are very fast. Thanks.

I'm still waiting for the update.

Ahelpyguy
Ahelpyguy India
on 11-May-10 5:02 AM
Hi Rishi,

This is great. I am beginner and started writing small application where person can type his first name and last name.

I am new to this. How to add this dll file and how to add the control?

can you have a small demo or video of adding this dll or source to have the keyboard running.

Thanks and keep up the gr8 work.


Ahelpyguy
Ahelpyguy India
on 12-May-10 12:06 AM
And finally your sample code worked. Smile

Rishi
Rishi
on 12-May-10 3:59 AM
@Ahelpguy, glad it worked for you. Also, FYI there is a sample application on Codeplex, see http://slik.codeplex.com

Rishi

Ahelpyguy
Ahelpyguy India
on 12-May-10 9:29 PM
Hi Rishi,

I am now creating one application which will contains first name, last name and some user info. Now to make the keyboard visible everytime.

I can see keyboard once i click on any textbox but unless user do not click he will see any keyboard?

How to make it permanently visible?

I did not find any property for that.

Ahelpyguy
Ahelpyguy India
on 13-May-10 7:33 AM
@ralf, found the problem and the solution. The problem is that a ChildWindow is not part of the Application RootVisual's VisualTree - which meant that we can only look for elements by name after the ChildWindow's VisualTree is itself initialized. And so as a solution, I've now put in place a check to wait till the VisualTree of the ChildWindow is loaded, and then only we try n' resolve the Keyboard.

Give me a little while n' I'll push the updates onto Codeplex.
Rishi
======================

Hi Rishi,
I stuck at the same problem i guess. I have 2 pages.

One loads the keyboard fine. There is another button on the page1 which will load page2. Now i have same fields there. But somehow keyboard is throwing exceptions.

It is not loading the keyboard or page.

Let us know the solution

Rishi
Rishi
on 13-May-10 2:08 PM
@ralf @Ahelpyguy I've updated the keyboard on Codeplex to version 1.5.5 - which fixes the ChildWindow related bug and also adds support for attaching the keyboard with a RichTextBox in Silverlight 4.

Rishi

Rishi
Rishi
on 13-May-10 2:10 PM
@Ahelpyguy as far as I can tell from your described scenario the problem, as I mentioned before, is either because the specified keyboard is not in the name-scope of the Child Window (see my comment about it above) or you have not specified an application-wide keyboard if you intended to use one (you specify it using ApplicationInputKeyboard behavior).

Also, currently you can't (directly) make the keyboard permanently visible - however, you'll be able to do that with the upcoming version 2.0 Smile

ralf
ralf Germany
on 13-May-10 7:57 PM
@Richi - Great, version 1.5.5 is running with "ChildWindow" in my development project.

It is very goog idea for custom layouts. On my development project i need this as soon as possible.

How looks your Roadmap for using your keyboard inside a Datagrig?

Regards, ralf

Ahelpyguy
Ahelpyguy India
on 13-May-10 9:56 PM
Hi Rishi,

Gr8. It worked. Now i understood what Application wise behavior also. I am now using this keyboard on diff pages. But only small problem is,

When i use Application wise keyboard, the keyboard is showing at the left top on the page. It is not moving also.

When you declare keyboard on each page, it looks movable can be placed on the location you want.

I have few fields on the top and i want to place or show keyboard on the specific location on the page.

How to do that? any ideas


Ahelpyguy
Ahelpyguy India
on 13-May-10 10:57 PM
Done Rishi. I used it separately and used properties like "Strech". Worked fine. Looking for 2.0

Cheers!!!

ralf
ralf Germany
on 14-May-10 1:55 AM
@Richi, if I use the keybord inside a DataGrid with template columns with a TextBox. That's running.


Rishi
Rishi
on 17-May-10 1:36 PM
@ralf, as an idea, it is possible to create a behavior that can automatically attach/detach the keyboard to any control by tracking changes in the Visual Tree. Such a behavior might be useful for use in your data-grid, especially as an alternative to custom column templates.

Rishi

pingback
120.defutbolazo.com
on 20-May-10 10:22 AM
Pingback from 120.defutbolazo.com

Chevrolet R200 Installation, Kelly Blue Book R20 Suburban

Daniel
Daniel Switzerland
on 02-Jun-10 11:58 PM
Hi Richi

Is this behavior (automatically attach/detach the keyboard) available?

Rishi
Rishi
on 03-Jun-10 10:59 AM
@Daniel, no behavior to auto attach/detach keyboard is currently available - but as I said one could write it. I probably will do so too.

Cheers,
Rishi

sledorze
sledorze France
on 29-Jul-10 6:57 AM
I need to be able to controle the keyboard layout (at least qwerty / azerty modes). How can I do that?
I am fairly new to the dotNet world so be kind ;)
Thanks!

Rishi
Rishi
on 30-Jul-10 11:29 PM
@sledorze  the currently available version doesn't not allow you alter the layout or customize the look and feel. However, the next version would.

Cheers.

el_pikel
el_pikel Poland
on 04-Aug-10 11:01 PM
How can i attach keyboard to all textboxes?

Rishi
Rishi
on 05-Aug-10 2:14 AM
@el_pikel well it's not too hard, just write your custom behavior that traverses through the Visual-tree attaching the keyboard to whichever control you want.

Cheers,
Rishi

pingback
Pingback from alabamaweddings.interactiveinfonet.info

Alabama weddings - Wedding chapel - Alabama wedding chapel

pingback
Pingback from websiteofthestate.interactiveinfonet.info

Web site of the state - York state - State of michigan official web site

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading