天天看點

Windows Phone 7 TextBox全選擴充行為

我們在Web中可能會遇到這樣一種情況,就是在修改某個文本(如html中的input type="text")的值時,當文本聚焦時,會将文本全部選中,友善修改,而不需要一個個删除後修改。

 我隻将其中的代碼貼出來,就不一步步詳細說明了,大家可以通過Visual Studio 2010,或者Expression Blend去建立行為,上面兩篇文章都有說明。

TextBoxSelectAllOnFocusBehavior.cs  代碼

<a href="http://blog.51cto.com/attachment/201105/092239876.png" target="_blank"></a>

如果是使用VS去建立行為的,在調用行為時, 别忘了添加命名空間,具體可以參加下面的源代碼。來看下運作效果吧

<a href="http://blog.51cto.com/attachment/201105/092300228.png" target="_blank"></a>

 源代碼下載下傳:

<a target="_blank" href="http://alexis.blog.51cto.com/attachment/201105/2621421_1306459444.rar"></a>

參考

<a href="http://mark.monsterconsultancy.nl/2011/04/13/silverlight--windows-phone-7-behavior-to-enhance-usability-of-textboxes?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed:+MarkMonster+%28Mark+Monster%29">http://mark.monsterconsultancy.nl/2011/04/13/silverlight--windows-phone-7-behavior-to-enhance-usability-of-textboxes?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed:+MarkMonster+(Mark+Monster)</a>

<a href="http://down.51cto.com/data/2358247" target="_blank">附件:http://down.51cto.com/data/2358247</a>

    本文轉自xshf12345 51CTO部落格,原文連結:http://blog.51cto.com/alexis/575302,如需轉載請自行聯系原作者