locked
how to xaml objects without sender RRS feed

  • Question

  • I am attempting to create a xaml object in a function that is not directly called by some event action on screen. Most functions have a (sender, args) but this doesnt.

    How can I gain access to the xaml object so that I then get access to the xaml things under that main canvas? 

    This is this code on the html side

    <div id="SilverlightControlHost">

    <asp:Xaml ID="sl" runat="server" Width="800" Height="800" XamlUrl="~/Scene.xaml"></asp:Xaml>

     

    </div>

     

    Wednesday, January 16, 2008 10:55 AM

Answers

All replies

  • here is what I tried

     

    var sl = document.getElementById("sl"); // this is the XAML object in the div

    var c = sl.content.findName("c1"); // this is a canvas inside the XAML (its not the main canvas)

    var cc = c.content.createFromXaml('<TextBlock Text=""BLAH"" Canvas.Top=""50"" />');

    c.children.Add(cc);

    I keep getting an unspecified error on the var cc = c.content line. 

     

     

     

    Wednesday, January 16, 2008 11:42 AM
  • some further digging.

     

    Main is the correct control and

    Var c is equal to the correct canvas that I want to put the objects into.

     

    Wednesday, January 16, 2008 12:12 PM
  •  

    new code, getting a different error.

    var c = Main.findName("c1");

     

    var c1 = c.getHost();

    var cc = c1.content.createFromXaml('<TextBlock xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="$tb" width="100" height="30" Text="BLAH" Canvas.Top="50" />');

    c.children.Add(cc);

     error is AG_E_RUNTIME_METHOD: CreateFromXaml

     

    Wednesday, January 16, 2008 12:15 PM
  • I think, createFromXaml() needs 2 params, your string, and then either a true or false value I believed used for async.


    var cc = c1.content.createFromXaml('<TextBlock xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="$tb" width="100" height="30" Text="BLAH" Canvas.Top="50" />', false);

    Wednesday, January 16, 2008 5:04 PM
  • Darn, that didnt help. still getting the the runtime error on the create command.

    Wednesday, January 16, 2008 5:57 PM
  • Friday, January 18, 2008 2:50 AM