Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug Silverlight hangs on Content="{TemplateBinding Content}
14 replies. Latest Post by Grey Matter on June 26, 2009.
(0)
bschwehn
Member
24 points
13 Posts
03-07-2008 4:30 PM |
Hello, I'm just evaluating the current SL 2.0 beta build. When trying the "Changing the Appearance of an Existing Control" Quickstart (http://silverlight.net/Quickstarts/BuildUi/47391440-987f-43d8-a4e4-b04a8133a5cc.aspx I've run into problem, that causes Silverlight to hang. The minimal repro case is this: When running from Visual Studio 2008 in debug mode it causes IE to hang with Devenv.exe and IEplore.exe using 100% CPU. Running without a debugger attached causes both IE and Firefox to hang with 100% CPU. When I remove the Content="{TemplateBinding Content}" part, silverlight starts again. Is the code wrong or is this a known problem? Any help is appreciated. My Test system is running Vista x64 SP1. Enjoy your weekends! Ben
03-07-2008 4:33 PM |
Ok, looks like the forum doesn't work in opera, trying to post again, hopefully retaining my formatting and tags...
I'm currently evaluating the current SL 2.0 beta build. When trying the "Changing the Appearance of an Existing Control" Quickstart (http://silverlight.net/Quickstarts/BuildUi/47391440-987f-43d8-a4e4-b04a8133a5cc.aspx I've run into problem, that causes Silverlight to hang.
The minimal repro case is this:
<UserControl x:Class="TestApp1.Appearance" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300"> <StackPanel>
<StackPanel.Resources> <Style TargetType="Button" x:Key="buttonStyle"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid x:Name="ELEMENT_Root"> <Rectangle x:Name="Base" RadiusY="2" RadiusX="2" /> <ContentPresenter Content="{TemplateBinding Content}" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </StackPanel.Resources>
<Button Content="Button 1" Style="{StaticResource buttonStyle}"/> </StackPanel></UserControl>
When running from Visual Studio 2008 in debug mode it causes IE to hang with Devenv.exe and IEplore.exe using 100% CPU. Running without a debugger attached causes both IE and Firefox to hang with 100% CPU.
When I remove the Content="{TemplateBinding Content}" part, silverlight starts again.
Is the code wrong or is this a known problem? Any help is appreciated.
My Test system is running Vista x64 SP1.
Enjoy your weekends!
Ben
Keith.Ma...
Participant
872 points
131 Posts
03-07-2008 9:51 PM |
Hi Ben,
Please try and add TargetType="Button" on the ControlTemplate in the Style
i.e
<Style TargetType="Button" x:Key="buttonStyle"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button" > <Grid x:Name="ELEMENT_Root">
03-08-2008 4:29 AM |
Hi Keith,
I tried your suggestion, unfortunatly Silverlight still hangs, didn't seem to make any difference.
Can anyone actually reproduce the hang?
03-08-2008 4:54 AM |
I believe the hang could be caused by some interaction with my graphics card driver. I have just updated the drivers for my GeForce 8600 GTS from the latest offical release (169.25) to the latest beta (169.44). Now Silverlight still hangs with 100% CPU but in addition it now also rapidly leaks memory...
03-08-2008 5:33 AM |
Well, I've reverted back to my old graphics driver and the memory leak is still there. Either I didn't notice the leak before or the beta drivers changed something that uninstalling didn't undo or the leak had nothing todo with the graphics card in the first place, dunno... Guess I'll try running Silverlight in a VPC image and hope it works better there...
03-08-2008 8:24 AM |
Hangs in XP Sp2 x32 running in VPC as well.
I have uploaded the test here:
http://bschwehn.de/temp/sl/test.html
I'd appreciate any feedback if this hangs and leaks for other people too.
Thanks
03-08-2008 9:21 PM |
Hi Ben,I am seeing the hang by navigating to your link, but I do not see it when I copy and paste your xaml into Visual Studio and build it myself. Could you please share out your Visual Studio Solution so I can take a look at it?
03-09-2008 5:17 AM |
Hello Keith thanks for looking into this.
Here's the SL app with VS solution:
http://bschwehn.de/temp/sl/Silverlightttests.zip
The test link didn't run on an IIS Server, so it doesn't use the aspx/ajax page but test.html
It's pretty much all copy'n'paste from the quick starts.
Yi-Lun L...
All-Star
25052 points
2,747 Posts
03-10-2008 2:08 AM |
Hello, actually the problem is, you're referencing to StaticResources that don't exist. As soon as you add the resources, it should be OK. One more thing, there're some problems on the quick starts. The root Grid's name should be RootElement, rather than ELEMENT_Root...
03-10-2008 6:24 AM |
Hello Yi-Lun Luo,
well, that was easy :)
Thanks a lot. Hope beta 2 will give an error message instead of a hang :)
03-10-2008 12:03 PM |
I had another look at this problem. Adding the resource bit fixed the problem for the code I uploaded, but I unfortunately didn't upload the minimal code example which is just:
<
</
http://bschwehn.de/temp/sl/Silverlighttests2.zip
As you can see, I'm not referencing any missing resources but SL still hangs. I don't know, but I think this might be an additional issue perhaps? Anyways, your suggestion fixed the problem for the full example.
03-10-2008 10:40 PM |
I think it is because you missed TargetType="Button" on the ControlTemplate tag. As soon as I added that property, it worked fine.
oohogwash
28 points
22 Posts
04-03-2008 6:57 AM |
I have the same problem in a totally different project, I seem to have all of the code in place mentioned in this list so far. The work around I used was to use a different property, in my case I used Tag.
Grey Matter
39 points
108 Posts
06-26-2009 5:09 AM |
I've met the same trouble too. My VisualStudio hangs while the following XAML is starting:
<UserControl x:Class="exam1.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <UserControl.Resources> <ControlTemplate x:Key="ButtonTemplate" TargetType="Button" > <Border BorderBrush="Orange" BorderThickness="3" CornerRadius="10" Background="Red"> <ContentPresenter Content="{TemplateBinding Content}" > </ContentPresenter> </Border> </ControlTemplate> </UserControl.Resources> <Canvas Background="YellowGreen" Width="200" Height="200"> <Button Template="{StaticResource ButtonTemplate}" Content="A Templated Button"/> </Canvas> </UserControl>