<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.silverlight.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Silverlight Controls and Silverlight Toolkit</title><link>http://forums.silverlight.net/forums/35.aspx</link><description>Discussions around using and developing Silverlight controls and the Silverlight Toolkit</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>Re: Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/327499.aspx</link><pubDate>Fri, 27 Nov 2009 15:36:46 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:327499</guid><dc:creator>RobertMcCarter</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/327499.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=327499</wfw:commentRss><description>&lt;p&gt;While modifying a few other controls on my page, I started getting &amp;quot;&lt;i&gt;&lt;font face="courier new,courier"&gt;AG_E_PARSER_BAD_PROPERTY_VALUE&lt;/font&gt;&lt;/i&gt;&amp;quot; errors on controls that I haven&amp;#39;t touched in weeks, and on properties that are completely valid and normal (and have been working for weeks).&lt;/p&gt;&lt;p&gt;This is very very odd, please address this problem.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/327495.aspx</link><pubDate>Fri, 27 Nov 2009 15:13:40 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:327495</guid><dc:creator>RobertMcCarter</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/327495.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=327495</wfw:commentRss><description>I&amp;#39;m voting for this as well - &amp;quot;&lt;font face="courier new,courier"&gt;&lt;i&gt;this.DataContext = this&lt;/i&gt;&lt;/font&gt;&amp;quot; is often very useful, and getting a &amp;quot;&lt;i&gt;&lt;font face="courier new,courier"&gt;AG_E_PARSER_BAD_PROPERTY_VALUE&lt;/font&gt;&lt;/i&gt;&amp;quot; is definitely NOT helpful, and in no way actually describes the problem.&lt;br /&gt;</description></item><item><title>Re: Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/305178.aspx</link><pubDate>Mon, 19 Oct 2009 19:46:51 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:305178</guid><dc:creator>snortblt</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/305178.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=305178</wfw:commentRss><description>Agreed. This is very frustrating. Certainly this must be a very common use case. If loaded doesn&amp;#39;t really mean everything&amp;#39;s loaded, its nearly useless.</description></item><item><title>Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/305125.aspx</link><pubDate>Mon, 19 Oct 2009 18:19:30 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:305125</guid><dc:creator>centrox</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/305125.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=305125</wfw:commentRss><description>&lt;p&gt;I&amp;#39;m having the same issue here with SL3. &lt;/p&gt;
&lt;p&gt;Having nested templated objects, and setting breakpoints at all events, will ofcourse show us the order of things..&lt;br /&gt;Although I have not experienced random behaviour. It is always the same. &lt;/p&gt;
&lt;p&gt;In my situation the loaded event is the first of the following sequence of events: &lt;/p&gt;
&lt;p&gt;Loaded, &lt;br /&gt;&lt;font size="2"&gt;OnApplyTemplate,&lt;br /&gt;&lt;font size="2"&gt;ArrangeOverride,&lt;br /&gt;&lt;font size="2"&gt;LayoutUpdated&lt;br /&gt;&lt;br /&gt;Context of this list is a class inherrited from Control. And it is always in the same order.&lt;br /&gt;The first workaround&amp;nbsp;that i feel myself pushed into&amp;nbsp;by this framework is to put my &amp;#39;One time only&amp;#39;&amp;nbsp; logic in the layoutupdated class with a nasty alreadyfired flag. But i can&amp;#39;t beleve this is the only way to get things done after they have properly initialized and ready to use.&lt;br /&gt;&lt;br /&gt;Anyone else some thoughts?&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;Cheers Centrox&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/138175.aspx</link><pubDate>Wed, 26 Nov 2008 22:18:15 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:138175</guid><dc:creator>CleverCoder</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/138175.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=138175</wfw:commentRss><description>&lt;p&gt;This has also affected me. According to the docs:&lt;/p&gt;&lt;p&gt;&amp;quot;Occurs when a FrameworkElement has completed layout passes, has rendered, and is ready for interaction.&amp;quot; &lt;/p&gt;&lt;p&gt;Nay!&amp;nbsp; I have a Popup control that contains an ItemList. I have attached a handler to the ItemList.Loaded event.. and it seems that every so often (perhaps 1/10 of the time), I can&amp;#39;t get the ActualWidth of the ItemList in that Loaded event. This causes bad behavior when the position of the list needs to be positions when it is loaded. Bad things happen 8*(&lt;/p&gt;&lt;p&gt;Anyone else seen this? I think hooking up the LayoutUpdated and checking ActualWidth for non-zero might be the only solution for now.&lt;/p&gt;&lt;p&gt;Boooo! &lt;img src="http://silverlight.net/emoticons/emotion-41.gif" alt="Ick!" /&gt; &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/121065.aspx</link><pubDate>Thu, 30 Oct 2008 13:15:44 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:121065</guid><dc:creator>Iceczd</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/121065.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=121065</wfw:commentRss><description>&lt;p&gt;In Silverlight 2 Beta 2. The Loaded event would occur once the control was rendered, now in the Release it seems to Happen before.&lt;/p&gt;
&lt;p&gt;This broke my workaround for an issue with the scrollviewer class being rendered with too many child objects at once (causing many height calculations and whatnot)&lt;/p&gt;
&lt;p&gt;Silverlight Devs,&amp;nbsp;take&amp;nbsp;these issues&amp;nbsp;Seriously! &lt;/p&gt;
&lt;p&gt;And please realize everytime you make a change your affecting thousands of peoples code. &lt;/p&gt;
&lt;p&gt;The font change from b2 to rc1 was enough. We&amp;#39;ve had to reformat loads of content to compensate.&lt;/p&gt;</description></item><item><title>Re: Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/120278.aspx</link><pubDate>Wed, 29 Oct 2008 15:03:18 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:120278</guid><dc:creator>andulvar</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/120278.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=120278</wfw:commentRss><description>Who keeps marking this as answered?&amp;nbsp; Nobody has even replied to it.&lt;br /&gt;</description></item><item><title>Re: When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/115105.aspx</link><pubDate>Wed, 22 Oct 2008 10:40:50 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:115105</guid><dc:creator>andulvar</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/115105.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=115105</wfw:commentRss><description>&lt;p&gt;I&amp;#39;ve been wrestling with this some more.&amp;nbsp; Since &amp;quot;Loaded&amp;quot; does not tell us anything about the state of either the parent or the children of a control, it is the wrong event in which to handle logic that relies on the hierarchy.&amp;nbsp; We need two new events, both of which fire immediately before the root object is returned from XamlReader.Load() or whatever function internally loads object hierarchies.&lt;/p&gt;&lt;p&gt;The first event should propagate from the root of the hierarchy to the leaves, called something like &amp;quot;ParentReady&amp;quot;.&amp;nbsp; Its purpose is to say &amp;quot;The entire tree is now loaded, initialized and rendered, and&amp;nbsp; your parent has processed its ParentReady event.&amp;quot;&amp;nbsp; This is the event that tells the object that its parent has done whatever initialization that its children must rely on.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The second event should propagate from the leaves of the hierarchy to the root, only after the entire hierarchy has processed &amp;quot;ParentReady&amp;quot;.&amp;nbsp; This second event could be called &amp;quot;Ready&amp;quot; and would be the last event transmitted before the loading process is done.&amp;nbsp; The purpose of the &amp;quot;Ready&amp;quot; event is to tell an object that its children have completed any initialization that the parent must rely on.&lt;/p&gt;&lt;p&gt;The important criteria before these two events fire would be:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Every object in the hierarchy has had its templates loaded and resolved. &lt;br /&gt;&lt;/li&gt;&lt;li&gt;Every object in the hierarchy has processed its Loaded event, if it has one.&lt;/li&gt;&lt;li&gt;Every object in the hierarchy has processed OnTemplateApplied if it has one.&lt;/li&gt;&lt;li&gt;Every DependencyObject in the hierarchy is in a fit state to act as a DataContext.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;This would resolve many outstanding issues that I see in the forums, like:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;I can&amp;#39;t assign &amp;quot;this.DataContext = this;&amp;quot;&lt;/li&gt;&lt;li&gt;I can&amp;#39;t assign &amp;quot;this.DataContext = child_object;&amp;quot; sometimes&lt;/li&gt;&lt;li&gt;When Loaded fires, I don&amp;#39;t know if my child object is loaded yet because order is seemingly random &lt;/li&gt;&lt;li&gt;Loaded events fire in different order depending on whether a child uses a template&lt;/li&gt;&lt;li&gt;A child that is valid as a DataContext becomes invalid if it uses a template&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>When is an object hierarchy completely loaded? Loaded event is unreliable.</title><link>http://forums.silverlight.net/forums/thread/114323.aspx</link><pubDate>Tue, 21 Oct 2008 12:42:15 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:114323</guid><dc:creator>andulvar</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/114323.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=35&amp;PostID=114323</wfw:commentRss><description>&lt;p&gt;I have an application that is causing me grief with the Loaded event.&amp;nbsp; I derive a class from Grid (call it Outer), and a class from DependencyObject (call it Inner).&amp;nbsp; Inner is a child of Outer.&amp;nbsp; When both are loaded I want to assign Inner as the DataContext of Outer.&amp;nbsp; Logically, I should do this work in the Loaded event of Outer.&amp;nbsp; Alternatively, I could do this work in the OnApplyTemplate method of Outer.&amp;nbsp; It doesn&amp;#39;t work reliably because I cannot predict whether Inner exists when Outer&amp;#39;s Loaded event fires.&amp;nbsp; &lt;/p&gt;&lt;p&gt;If Inner is fully defined within the XAML of Outer, it appears to work.&amp;nbsp; If Inner is templated, so that its own properties are assigned through {StaticResource...} then Inner is not yet defined when Outer&amp;#39;s Loaded event fires.&amp;nbsp; Consequently when I assign Outer.DataContext = Inner, this throws an error (argument is out of expected range) presumably because Inner has not yet been initialized in some fashion.&amp;nbsp; This post: &lt;a href="http://silverlight.net/forums/p/11996/39114.aspx#39114"&gt;http://silverlight.net/forums/p/11996/39114.aspx#39114&lt;/a&gt; implies that the order is fixed.&amp;nbsp; It clearly is not.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I&amp;#39;m doing all this because if I try to assign Outer as its own DataContext (basically: this.DataContext = this), it always fails with the same error message.&amp;nbsp; It looks like the object state has to pass a certain point in the construction process before it can be assigned as a DataContext.&lt;/p&gt;&lt;p&gt;I tried to make Inner a FrameworkElement or a Control so I could count Loaded events, and do the work only when two Loaded events have occurred.&amp;nbsp; This can only work because Inner and Outer are both my code, and they know about each other.&amp;nbsp; The problem is that Inner&amp;#39;s Loaded event can fire zero, one or multiple times.&amp;nbsp; I haven&amp;#39;t figured out what causes that, other than to note that if there is a try/catch in some processing that precedes Inner&amp;#39;s Loaded event, and an error is caught, this could stop Inner&amp;#39;s Loaded event from happening at all.&amp;nbsp; In the debugger I once saw Inner&amp;#39;s Loaded event get called 6 times in a single run.&amp;nbsp; I can&amp;#39;t tell you why.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I considered calling ApplyTemplate manually in the Loaded event of Outer.&amp;nbsp; Unfortunately, Grid does not have an ApplyTemplate method.&amp;nbsp; Why not?&amp;nbsp; It has an OnApplyTemplate override.&amp;nbsp; Strangely, the OnApplyTemplate method of Outer never actually gets called.&amp;nbsp; If I make Inner into a FrameworkElement, its OnApplyTemplate never gets called either.&lt;/p&gt;&lt;p&gt;I&amp;#39;ve read this post: &lt;a href="http://silverlight.net/forums/p/27294/93181.aspx#93181"&gt;http://silverlight.net/forums/p/27294/93181.aspx#93181&lt;/a&gt; which deals with the question of Loaded order somewhat, but doesn&amp;#39;t address the issue for objects without an ApplyTemplate method.&amp;nbsp; It also doesn&amp;#39;t address the issue of Loaded firing a random number of times.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;So, after all this, I have one simple question:&lt;/p&gt;&lt;p&gt;At what point in the code can I be guaranteed that my object (in general, a DependencyObject) and all of its children are completely loaded?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>