Creating button in SL using createFromXaml()
-
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*
-
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*
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:
-
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: