Skip to main content
Microsoft Silverlight
Home Forums Silverlight Design Designing with Silverlight how to dynamically change the text
3 replies. Latest Post by dreamtv on February 27, 2008.
(0)
dreamtv
Member
50 points
28 Posts
02-26-2008 8:51 PM |
Using TextBlock object and I want to dynamically change the Text property in this object. My xaml file looks like this -
<TextBlock x:Name="channel_txt" FontSize="20" Canvas.Left="320" Canvas.Top="46.566" FontFamily="Arial"><TextBlock.Foreground> <SolidColorBrush/> </TextBlock.Foreground><Run Foreground="#FF98AAD2" Text=""/></TextBlock>
And in the javascript I get access to the "channel_txt" object and do the following -
var channel_txt = host.content.findName("channel_txt");
channel_txt.Text = "Channel 1 World Chess";
But the Text field in the TextBlock is not updated. - Can I do this or is there any another way to update the text dynamically.
I also tried the channel_txt.SetVal() function as well but it doesn't work.
Thanks
mchlsync
Star
14608 points
2,732 Posts
02-26-2008 9:00 PM |
dreamtv:var channel_txt = host.content.findName("channel_txt");
Are you able to get the textbox object? If you are familiar with Firebug, you can put the breakpoint in that line and see whether you got the object or not. I'm not sure whether you should use "host.content.findName" or not. but In SL 1.1, we can use this.FindName("channel_txt"); in managed code.
02-26-2008 9:46 PM |
Actually alert() worked and I used to see channel-txt object and it was a TextBlock object. Is there any other way I can do this?
thanks
02-27-2008 7:31 PM |
When I used the "Text" property in the main <TextBlock> instead of <TextBlock.foreground>, I was able to update the text dynamically.