views:

236

answers:

2

Hey!

Ok I have the following problem in Silverlight. I have a control with 2 columns. On the left is a stack panel with line numbers and on the right is a textBox.

So when I write in textBox without wrapping turned on I can simply create the right count of numbers on the left, because I'm searching for '\r' in text.

But when I turn on wrapping I have no control over the count of lines in textBox.

Is there a way to get to that count? Or a way to know which line in textBox is going to wrap?

I hope you can understand what I'm trying to do.

A: 

Hi there,

Is it not possible to create your items in code before they are passed to the view. This would enable you to bind a list of items to a listview and style them as you wish.

Blounty
Yes I'm creating them in code, becouse I know the number of lines in textBox. But when I enable wrapping new lines are created because of that and then I cant get the correct number any more.
Gapipro
A: 

You need to user a value converter to count the number of char / lines and then trim that number if you wish to. Unless you use fixed width, you can't really count or calculte in advancet the size, since each application might be displayed differently (due to different sizing option).

There are two great sample chapters on Windows Phone and Silverlight for Windows Phone on the LearningWindosPhone.com site. There is great Windows Phone Trainng material , and dont forget the Windows Phone Develoeprs Blog

Yochay Kiriaty
Hm, if I use a font that has all characters of same width then I can calculate the max number if characters/line even if I have dynamic textBox. Is that correct?
Gapipro