locked
how to dynamically change the text RRS feed

  • Question

  •  

    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

    Tuesday, February 26, 2008 8:51 PM

Answers

  •  

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

     

    Wednesday, February 27, 2008 7:31 PM

All replies

  • 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.

    Tuesday, February 26, 2008 9:00 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

     

    Tuesday, February 26, 2008 9:46 PM
  •  

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

     

    Wednesday, February 27, 2008 7:31 PM