I have had this requirement since last week about putting a limit on the number of lines you can write in a multiline (AcceptsReturn=true) TextBox in Silverlight 4 and was disappointed to know that there is currently no way you do it like in WPF. In WPF, the TextBox control has an integer property called MaxLines which you can set to limit the number of lines. In Silverlight, there seems to be no way because you wouldn’t possibly know when or where in the string a word wrap split has occurred. It would be simple if you are using a fixed-width font like Courier/CourierNew because you can simply count the number of characters that would fit in one line, but in my case, its Comic Sans. The client insisted that they wanted this feature so I decided to write my own logic to simulate the word wrap algorithm used in Silverlight TextBoxes. Below is the result of what I did. The object below is a Silverlight textbox with MaxLines property set to 6.What I did was I extended the Silverlight TextBox control and added my own logic to simulate how the word wrap behaves.
You may get the full source code of the extended textbox here. Enjoy!
Friday, August 19, 2011
Saturday, January 22, 2011
Timer for Android – Make a TextView Blink
I am pretty sure some of you may been through the same problem where you needed a simple periodic timer for your Android app. You may use java.util.Timer but this is not a good choice as this timer creates a new thread for some reason and you don’t want to invoke multiple threads in your mobile app. So I created this simple timer that makes use of the android.os.Handler class. Below is the source code of the Timer for android. Sorry for the formatting and naming convention. I’m used to the C# conventions.
I used this timer to make a TextView in my Application blink, to update values in the UI from service, to monitor status, etc. with the following code:
Subscribe to: Posts (Atom)
Part 4/4 - Deploying Openshift/OKD 4.5 on Proxmox VE Homelab This is the last part of a 4-part series on Running Openshift at Home. Some inf...
Due to an unfortunate event related to the coronavirus pandemic, I have been repatriated back to the Philippines from Singapore. I have now ...
Part 1/4 - Homelab Hardware Part 2/4 - DIY Silent Server Cabinet Part 3/4 - Installing a Two-Node Proxmox VE Cluster Part 4/4 - Deploying O...