Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Creating button in SL using createFromXaml()

Creating button in SL using createFromXaml()

Scheduled Pinned Locked Moved WPF
javascripthtmlcsswpfcom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxxbin
    wrote on last edited by
    #1

    Hi, I'm using Silverlight.createObject() and createFromXaml() Javascript functions to render some XAML files. This works great but the Button element not. I can make some TextBlock, TextBox, Grid, StackPanel, and more controls, but the simple Button I can't be added to my dynamic XAML. Someone could explain me this? My code is something like this:

    Javascript

            function embedSilverlight(parentElement, pluginId, userContext)
            {
                return Silverlight.createObject("sample.xaml",
                    parentElement, pluginId,
                    { 
                        width: 500, background: "white", alt: 'No Silverlight', 
                        version:"2.0.31005.0", autoUpgrade:true
                    },
                    {
                        onError: onSLError,
                        onLoad: function(plugIn, userContext, sender)
                        {
                            var xamlFragment = $(parentElement.id + '\_xaml').get('html');
                            xamlFragment = xamlFragment.substr(12, xamlFragment.length - 18);
                            var child = plugIn.content.createFromXaml(xamlFragment, false);
                            sender.children.add(child);
                        }
                    },
                    "", userContext);
            }
    
            function onSLError(sender, args)
            {
                // Display error message.
            }
    

    sample.xaml

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Name="slView">
    

    And the content are snippets like:

    Form SilverlightName*

    M 1 Reply Last reply
    0
    • H hxxbin

      Hi, I'm using Silverlight.createObject() and createFromXaml() Javascript functions to render some XAML files. This works great but the Button element not. I can make some TextBlock, TextBox, Grid, StackPanel, and more controls, but the simple Button I can't be added to my dynamic XAML. Someone could explain me this? My code is something like this:

      Javascript

              function embedSilverlight(parentElement, pluginId, userContext)
              {
                  return Silverlight.createObject("sample.xaml",
                      parentElement, pluginId,
                      { 
                          width: 500, background: "white", alt: 'No Silverlight', 
                          version:"2.0.31005.0", autoUpgrade:true
                      },
                      {
                          onError: onSLError,
                          onLoad: function(plugIn, userContext, sender)
                          {
                              var xamlFragment = $(parentElement.id + '\_xaml').get('html');
                              xamlFragment = xamlFragment.substr(12, xamlFragment.length - 18);
                              var child = plugIn.content.createFromXaml(xamlFragment, false);
                              sender.children.add(child);
                          }
                      },
                      "", userContext);
              }
      
              function onSLError(sender, args)
              {
                  // Display error message.
              }
      

      sample.xaml

      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      x:Name="slView">
      

      And the content are snippets like:

      Form SilverlightName*

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      What am I missing? I don't see anything related to a button control in your post... :) Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      H 1 Reply Last reply
      0
      • M Mark Salsbery

        What am I missing? I don't see anything related to a button control in your post... :) Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        H Offline
        H Offline
        hxxbin
        wrote on last edited by
        #3

        Yes, sorry, but the point is when I try to add a child Button in my canvas, I can't do it. It returns me a Javascript error saying the Button element is unknown.

        ---- hxxbin

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups