|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionWhile digging into Silverlight 2 Beta 2 I have noticed that there is no Password Box available. It will be in a finall version but till then we have to figure out some other way to do it. This solution is quick and maybe even a little bit dirty but it works what makes it valuable enough to be posted :) Using the codeJust attach the
string _currentText = "";
void tbPassword_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox __textBox = sender as TextBox;
if (__textBox != null)
{
string __currentText = __textBox.Text;
if (__currentText.Length < _currentText.Length)
_currentText = _currentText.Substring(0, __currentText.Length);
if (__currentText != "")
{
for (int i = 0; i < __currentText.Length; i++)
{
if (__currentText[i] != '\u25CF')
{
string __temp = __currentText.Remove(i, 1);
__textBox.Text = __temp.Insert(i, "\u25CF");
_currentText = _currentText.Insert(_currentText.Length, __currentText[i].ToString());
}
}
}
}
}
In the _ Points of InterestI am working on quite big RIA Silverlight application. Lacking this basic password box made my stomach aches. Hopefully in final release of Silverlight we wont have such issues anymore. HistoryWhile creating this small sample I was inspired by Michael Sync post. Unfortunatly, Silverlight 2 beta 2 sample source code did not work properly that is why I decided to write simplier solution (IMHO).
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||