Skip to main content

Answered Question how to dynamically change the textRSS Feed

(0)

dreamtv
dreamtv

Member

Member

50 points

28 Posts

how to dynamically change the text

 

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
mchlsync

Star

Star

14608 points

2,732 Posts

Silverlight MVP

Re: how to dynamically change the text

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.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


dreamtv
dreamtv

Member

Member

50 points

28 Posts

Re: how to dynamically change the text

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

 

dreamtv
dreamtv

Member

Member

50 points

28 Posts

Answered Question

Re: how to dynamically change the text

 

When I used the "Text" property in the main <TextBlock> instead of <TextBlock.foreground>, I was able to update the text dynamically.

 

  • Unanswered Question
  • Answered Question
  • Announcement