Its set of workarounds only.There is no support in silverlight 2.0 to have a multiline textbox.But we should accomplish as we might be in deadline :-).It leads to workarounds.
What I did ,was to set AcceptsReturn property of TextBox.Now it will accept Returns ie EnterKey and create one more line by increasing its' Height.
Now the next problem came.ScrollBars..
I tried setting ScrollViewer.VerticalScrollBarVisibility="Visible".But it gave me runtime error.(Dont know why VS2008 showed intellisense to add ScrollViewer.VerticalScrollBarVisibility="Visible").
Again workaround.Put this TextBox in a ScrollViewer.
Finally it looks like
<ScrollViewer Height="100" Width="100" HorizontalScrollBarVisibility="Visible">
<TextBox Text="Javascripting Silverlight 2.0"
AcceptsReturn="True"
/>
ScrollViewer>
Sample located here
4 comments:
Instead of emulating a scrollable textbox, you can use the built-in features of the textbox and use it like this :
<TextBox
VerticalScrollBarVisibility=”Visible”
HorizontalScrollBarVisibility=”Auto”
AcceptsReturn=”True” />
Thats a good idea :-)
You should add Wrap so that you have multiple lines as below...
For Multiple Lines in Text Box following code is fine if it is a TextBlock then you need to have ScrollViewer to acive this...
Post a Comment