Skip to main content
Home Forums Silverlight Programming Programming with JavaScript ParserError- Unknown element: Button
9 replies. Latest Post by slyi on October 29, 2009.
(0)
ritesh t...
Member
2 points
7 Posts
10-23-2009 2:54 AM |
Hi, I am using Silverlight 3. I am creating a Silverlight web script application. I have made sure that Silverlight 3 is installed. Please let me know any reason for this issue
anil_litam
558 points
262 Posts
10-23-2009 3:08 AM |
Hi,
Is XAML showing this error..?
Please share your XAML code for better understanding..
10-23-2009 3:11 AM |
Jonathan...
All-Star
24947 points
2,427 Posts
10-28-2009 3:56 AM |
Hi Ritesh,
How's your issue going now? Please compare your code with the below sample.
<UserControl x:Class="SLProjectTest.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot"> <Button Content="btn" Width="150" Height="30"></Button> </Grid> </UserControl>
Best regards,
Jonathan
10-28-2009 6:03 AM |
Hi Jonathon,
The issue is still not fixed. I am creating a Silverlight script application for which it is failing.
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Background="LightYellow" > <Grid.RowDefinitions> <RowDefinition Height="40" /> <RowDefinition Height="40" /> <RowDefinition Height="20" /> </Grid.RowDefinitions> <Grid Grid.Row="0" MouseLeftButtonUp="onMouseEnter" > <Grid.RowDefinitions> <RowDefinition Height="20" /> <RowDefinition Height="20" /> </Grid.RowDefinitions> <TextBox Grid.Row="0" Width="80" Text="GP 1" Visibility="Visible" /> <Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Grid.Row="1" Width="80" Content="GP 1" Visibility="Visible" /> </Grid> <Grid Grid.Row="1"> <Grid.RowDefinitions> <RowDefinition Height="20" /> <RowDefinition Height="20" /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Width="80" Text="GP 2" Visibility="Visible" /> <TextBlock Grid.Row="1" Width="80" Text="102" Visibility="Visible" /> </Grid> </Grid>
10-28-2009 6:16 AM |
Copied your code to my test sample and it works on my computer. Please take a look at the video tutorials here.
10-28-2009 7:12 AM |
hi Jonathan, Are you testing this in "Silverlight Script Web" or a "Silverlight application". It is working in "Silverlight application" on my side. I have any other query for the SIlverlight. Is it possible to create custom controls in Silverlight on the runtime on the server side.
Wolf Sch...
489 points
79 Posts
10-28-2009 3:44 PM |
Button is one of the objects that will require managed activation to use. This means that your application needs to not be using the web script application template; that template specifically avoids the settings that cause the SL runtime to load any of the managed/CLR components.
The list of objects that you can use without the managed activation is finite. For the most part it's the object set as documented in the existing MSDN reference section for JavaScript API for Silverlight: http://msdn.microsoft.com/en-us/library/bb980170(VS.95).aspx - there are also a few cases where maybe the parser w/o managed activation can create objects but you then get dead-ended because of how the runtime acts - an example of that case is <Style>.
If you can't go to managed runtime for whatever reason (some particular scenario, or you're writing a splash screen) your best bet may be to simulate a button with the panels you have available and handle MouseLeftButton down for click-type event.
10-28-2009 11:23 PM |
Ah. You are using Silverlight Script Web and Button is not supported in your scenario. Silverlight 1.0 is not commended. We can create a Silverlight 3 application. At the meanwhile, Javascript can be used to interact with our Silverlight application.
http://timheuer.com/blog/archive/2008/03/09/calling-javascript-functions-from-silverlight-2.aspx
http://weblogs.asp.net/mschwarz/archive/2007/06/01/call-scribtable-methods-from-javascript-with-silverlight.aspx
slyi
Participant
826 points
255 Posts
10-29-2009 1:03 PM |
In the JS object model your selection of controls is limited. What you can do is to extract the template of button using delay's SilverlightDefaultStyleBrowser and then style the usercontrol as button.
JS button sample on http://cid-289eaf995528b9fd.skydrive.live.com/self.aspx/Public/SLjQueryBinding.zip