/default.aspx
Silverlight .NET CMS and Controls
Home
/controls.aspx
Silverlight Controls
Controls
Textbox

Silverlight Textbox Control

This TextBox control is similar in functionality to standard web text boxes and has been developed for Microsoft's Silverlight technology. As with all our Silverlight controls this is a highly customizable control both visually and functionally.

How to Use the TextBox Control

In your XAML ensure you have a reference to the Liquid.dll in the UserControl tag at the top. To use the textbox on your Silverlight page:

<UserControl x:Class="TextBoxPlus.Page"
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:liquid="clr-namespace:Liquid;assembly=Liquid"
    Width="400" Height="300">
     <Canvas>
          <TextBlock x:Name="userNameLabel" Canvas.Left="0" Canvas.Top="52" Text="User Name:" FontFamily="Arial" />
          <TextBlock x:Name="passwordLabel" Canvas.Left="0" Canvas.Top="82" Text="Password:" FontFamily="Arial" />
          <liquid:TextBoxPlus x:Name="userName" Canvas.Top="50" Canvas.Left="80" Width="150" MaxLength="20" TabIndex="0" />
          <Grid Canvas.Top="80" Canvas.Left="80" Width="150">
               <liquid:TextBoxPlus x:Name="password" Grid.Column="0" Grid.Row="0" Width="Auto" Height="Auto" MaxLength="20" TabIndex="1" Password="True" />
          </Grid>
     </Canvas>
</UserControl>

 

In your Silverlight C# code behind file you can refer to the TextBoxes using firstName and lastName. This example contains two textboxes and demonstrates how Focus can be managed when using the vectorlight controls. Essentially the Root object is taking all keyboard input and is the handling Focus events for all controls. It also updates the controls when the Focus is lost for a particular control.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TextBoxPlus
{
     public partial class Page : UserControl
     {
          public Page()
          {
               InitializeComponent();
          }
     }
}

 

Example Silverlight TextBox Control:

Silverlight TextBox Control
  • Written in Client-Side C# .NET 3.5
  • Microsoft Silverlight Only
  • Standard and Enhanced Functionality
  • Character Input Control
  • Customizable Visual Feel

Your Comments and Questions Answered

 You are not logged in. You need to login to post new messages, if you do not have a login you can register for free!

Lee.Oades Aug, 18 2008 - 08:25

I have a Login control with a normal SL TextBox, followed by a TextBoxPlus set in password mode.
Place the cursor in the normal textbox and pressing Tab does not focus on the TextBoxPlus correctly. Pressing Tab once more does focus on the text area - but the focus is shifting to somewhere else in between.

Thanks,
Lee

 

dan Jun, 25 2008 - 00:13

Hello,

Thanks for the bug report, it seems the latest version still has issues with the Password mode, were looking at this at the moment and hope to have it fully resolved soon!

 

yjnull Jun, 23 2008 - 00:31

For your information... The password TextBox is still having some problem on it in version 4.7.

When replacing selected text at middle of the entire text, it couldn't fully be replace, or when backspace/delete at the middle of text also facing same problem...

Please take a view on it... I have checked the version before Silverlight 2 Beta 2 that is Version 4.5, the password textbox was just worked perfectly...

Looking forward to hear from you...

Thank you.

 

dan Jun, 20 2008 - 14:06

Hello,

The latest version 4.7 of the controls library fixes this problem and can be downloaded now!

 

dan Jun, 19 2008 - 23:52

Hello,

Thanks for the bug reports, we are aware of this problem and are resolving it at this moment. A new version of the controls will be available soon which will fix this issue!

 

khasmith Jun, 19 2008 - 13:36

I, too, am experiencing issues with using the TextBoxPlus control in password mode (version 4.6 SL 2 Beta 2). When I use the backspace or the delete keys in the password textbox the browser hangs.

Here's a the basic outline of the XAML that I am using, (I removed all the unnecessary attributes from the all the controls except the liquid textbox control)

    <Border>
         <Grid>
                <TextBlock Text="Username:" />
                <TextBlock Text="Password:" />
                <TextBox x:Name="txtUserName" />
                <liquid:TextBoxPlus Password="True" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,10,0" FontFamily="Arial" FontSize="10" Grid.Column="1" Grid.Row="2" d:LayoutOverrides="Height" Width="160" x:Name="txtPassword" Round="2" TabIndex="1" />
     <Button Content="Login" />
     <HyperlinkButton Content="Sign up, now." />
            </Grid>
     </Border>

Is there a fix for this?

Thanks,
KhaSmith

 

yjnull Jun, 16 2008 - 00:38

the password textbox in version 4.6 which is compatible with Silverlight 2 Beta 2 got some problem on it...
on copy text or undo will sometimes make the page hang...

please take a view on it...

hope to hear from you soon...

 

dan Jun, 06 2008 - 23:20

Hello,

Not at the moment, this would not be a huge task and is one we will consider in the future. Thanks for the suggestion!

 

rparsons Jun, 06 2008 - 13:29

Are there any plans to add a button or child array to the textbox so you can have a browse (...) or search (magnifying glass) button with in the textbox?

 

dan Jun, 03 2008 - 05:10

Hi Richard,

At the moment the foreground color has to be set in the control declaration only, this is on the list of improvements for the next version. The current version overrides any color setting in the style template which is a bit of a pain, but this will be fixed. Thanks for your patience!

 

rparsons Jun, 02 2008 - 08:46

I'm working on a custom template for the textbox and I'm having some difficulty setting the foreground color to something other than black. I copied the default template and have edited it to suit my needs but when add a foreground="#ffffffff" to the ElementText element the text color does not change.

Since I couldn't get the above to work I tried to set the foreground in the page.xaml where the control is actually defined. That worked well so I decided to put another Setter in the Style in my app.xaml but I get an "Invalid Property: Setter" error.

Is setting the foreground only available on the control definition or am I just missing something?

Thanks for the help,
Richard

 

dan May, 12 2008 - 05:34

Hello,

Thanks for the link, databinding is being looked at at the moment, we will update this page when we are nearer a solution!

 

omnius May, 09 2008 - 12:26

Do you have plans to support data binding like the standard Silverlight controls? This page has a good example of how databinding works with a standard textbox. http://www.u2u.info/Blogs/Peter/Lists/Posts/Post.aspx?ID=271

 

dan Mar, 04 2008 - 00:09

Hello,

As noted earlier, certain characters cannot be input into the textbox, we are working on a solution for this at the moment and your patience is appreciated.

 

Marek Bober Mar, 03 2008 - 06:35

Hello
why can I write other characters like (á, é) in national language?

 

dan Feb, 13 2008 - 00:43

Hello,

This is an interesting one, at the moment it is not possible to set the font source to a downloader object, this request has been added to the features list for the next version. In theory displaying non-standard fonts is possible, detecting the key presses would be more difficult and as Silverlight is still not officially released I'm not sure if it's even possible yet.

This is something we are looking into and anyone out there who may have come across working with Silverlight and non-English keyboards are welcome to share their ideas.

 

정진섭 Feb, 12 2008 - 15:50

hi dan


It will be able to set a font source with the down loader object?

I wants setting with the font where the Korean alphabet control is possible

 

dan Feb, 04 2008 - 07:34

The controls demo now has a javascript solution to the issue of tabbing between controls, we are still working on a full .NET solution.

 

dan Feb, 01 2008 - 00:09

Hello,

Sure, to enable password mode, in your textbox set the property Password = true. You can also change the character that is displayed by setting the PasswordCharater property. You must have Version 2.5 to use the password mode.

The TextBox Reference page a full list of available TextBox properties.

 

prejeshvp Jan, 31 2008 - 23:20

Hi dan,

Can u plz share how to use password mode in textbox

 

dan Jan, 31 2008 - 10:55

Hello,

Yes we are aware of this limitation and are currently working on a solution. Basically the tab event is picked up by Javascript first and precessed and then passed to Silverlight. So although the tab key could be detected and the focus moved between controls there is no way in .NET to stop javascript processing the tab key press event.

Not stopping the javascript keypress events would lead to the silverlight controls and HTML elements being tabbed at the same time causing unacceptable browser behaviour.

As I have said we are working on a solution for this at the moment which doesn't involve javascript as we are trying to keep these controls .NET only, any suggestions are welcome.

 

testuser Jan, 31 2008 - 08:57

The key down event is not firing when we press the tab button.
How do we move from controls to controls by pressing tab buttons?

 

dan Jan, 28 2008 - 00:32

Hello,

Version 2.4 should be completed by 31st Jan, regarding the TextBox border color and the rounded corners, the example under Visual Customizations gives an example of how to change the border color. Essentially the background of the TextBox is a Rectangle and using the skinning method in the example you can set the border color with:

skins.Add("TextBox.Background.Stroke", red);

To change the roundness of the corners using the example you would add the following to your skins collection:

skins.Add("TextBox.Background.RadiusX", 0);
skins.Add("TextBox.Background.RadiusY", 0);

The above would set both rounded properties to 0 removing the roundness.

 

prejeshvp Jan, 27 2008 - 20:43

Is 2.4 v released? can v change border color and rounded corner of a text box?

 

dan Jan, 27 2008 - 15:40

The multi-line TextBox is now available. This control is called the TextArea and is available in Version 2.4, information regarding the TextArea and how to implement it in your own Silverlight applications can be found under the TextArea section of the Controls menu to the top left of this page.

 

dan Jan, 19 2008 - 03:31

Hello,

At the moment the TextBox is only a single line textbox, a multi-line textbox is in development. The TotalHeight in the current textbox is only for reading. The height of the textbox is automatic based on the FontSize property.

As previously mentioned, a multi-line version is in development and is scheduled for completion soon.

 

prejeshvp Jan, 19 2008 - 02:28

hi Dan,
the TotalHeight property of the textbox does not work, plz help me out

 

dan Jan, 18 2008 - 12:27

Hi,

These controls can be used in Silverlight User controls just fine, the problem your having is down to the way Silverlight handles keyboard events. All key press events go to the Silverlight page only, it is the responsibility of the developer to filter the key press event down to the relevant child controls.

Taking the example code and using it in a User Control will not work, the Root object and the event key press event handling must be done in your Silverlight Page. Let us know if you still can't suss this out, or you can email your project to dan@vectorlight.net.

 

dmontooth Jan, 18 2008 - 11:05

I am trying to use your control within a custom silverlight control. I am unable to type in the textbox, the keydown event doesnt fire. Ive used the sample code above with no luck. Do these controls have to be used in a silverlight page or can they be used in a silverlight usercontrol?

 

dan Jan, 12 2008 - 00:52

Hi,

I have updated the example above to show how to manage focus using the Root object. Basically all vectorlight controls have a Root object, you need to declare a Root object at a Page (global) level and set the Root property of any vectorlight control to this global object.

Then when you handle key presses within your Silverlight Page you should call the KeyDown() method in the Root object and this will direct the key press event to the currently active textbox. The above revised example should help you with what you're trying to do.

Whilst testing this myself a bug became apparent, you must set the TotalWidth property in your XAML for your textbox controls as not setting this can affect the blink too, this has been added to the bug fix list for Version 2.2. Thanks for you help identifying these problems.

 

prejeshvp Jan, 11 2008 - 01:22

i have used ur textboxes in my sample application, it works great. u have done a great job. but caret wont stop blinking even when focus is moved out. if i have 3 textboxes in my app. if i enter data in all 3 , caret will be blinking in all 3

 

dan Jan, 09 2008 - 05:52

You need to ensure the OnKeyDown event is correctly set for your textbox. Because all keyboard events go to the Silverlight page you must implement logic to filter keypress events down to all the child textbox controls.

If you follow the example provided at the top of this page you should see how the event handling needs to be implemented.

 

prejeshvp Jan, 09 2008 - 01:31

textbox is control is not accepting text. why is it?

 
This page is 45.6KB and was generated by the SilverPages CMS in 0.031 seconds. Total impressions: 1301.