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!
Subscribe to:
Post Comments (Atom)
Featured
Architecting Systems Like A Rock Band
In Software, orchestration often means control, synchronization, mediation and scheduling of decoupled application services in order to ful...


Popular
-
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...
-
Chrono or Chronograph, the term used by Airsofter and Paintball players to refer to the device that measures the muzzle velocity of firearms...
-
I am currently in the process of learning Hadoop architecture, administration and the MapReduce programming model. I started reading about...

Amazing Article, Really useful information to all So, I hope you will share more information to be check and share here.
ReplyDeletePygame Tutorial
Pygame Download
Pygame Install
Matplotlib Python
Matplotlib Tutorial
Matplotlib install
PouchDB Tutorial
What is PouchDB
PouchDB Installation
pouchdb server