WPF-Blogger.com [Language: en] http://www.wpf-blogger.com All news and information about Windows Presentation Foundation and Silverlight at one place. Freitag, 30. Juli 2010 12 Absolutely and Insanely Essential Utilities For Programmers In every era in recent times there has been one profession that for a short while you could enter without formal training. Autodidacts in the 19th century could read the law without recourse to formal education (see Abe Lincoln). In the early 20th century it was aviation.&#160; For a short while in the 1980s and [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/qQ_5nXPKuUo/ Jesse Liberty [MS] 2261 2010-07-30T06:45:01 Announcing 2nd CTP of XAML Toolkit We are happy to announce the release of the second CTP of the XAMLToolkit. Where do i get it: LINK The toolkit comprises of: A XAML DOM Fxcop rule authoring support for XAML SilverlightSchemaContext that enables System.Xaml to parse SL XAML. We greatly...(<a href="http://blogs.msdn.com/b/llobo/archive/2010/07/30/announcing-2nd-ctp-of-xaml-toolkit.aspx">read more</a>)<img src="http://blogs.msdn.com/aggbug.aspx?PostID=10043247" width="1" height="1"> http://blogs.msdn.com/b/llobo/archive/2010/07/30/announcing-2nd-ctp-of-xaml-toolkit.aspx Lester Lobo 2260 2010-07-30T04:13:00 One From The Vault: Ranting About Editors This week&#8217;s One From The Vault is a rant on arbitrary and incorrect &#8220;rules&#8221; of English insisted upon by some teachers, editors and pedants: There is no excuse for thinking that you can’t start a sentence with “There is.”  And I should add that I think it is fine to start a sentence with “and.” [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/tHvTbjcb3Pw/ Jesse Liberty [MS] 2250 2010-07-26T03:37:38 Portland Silverlight User Group 10 Aug 2010 On 10 Aug 2010, Adam Kinney and I will be presenting at the Portland Silverlight User Group. As you know I work on the WPF &#38; Silverlight Designer in Visual Studio as part of the Expression Team. This session will provide guidance for writing applications that are toolable.&#160; Many folks use the term, Blendable. Do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1518&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/07/25/portland-silverlight-user-group-10-aug-2010/ Karl Shifflett [MS] 2248 2010-07-25T21:38:37 Data Validation And Templating in Silverlight 4 This is the fifth in a series on Templates and DataValidation. [ First In Series Previous In Series ] In this and the next posting I will create an application that will demonstrate how to modify the Visual State for invalid data. Along the way we will review: Binding form elements to data The binding [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/dHPh77CQk00/ Jesse Liberty [MS] 2247 2010-07-25T21:26:52 Video recordings for first Windows Phone 7 Jumpstart event <p>&nbsp;</p> <p>This week, MS learning did the first delivery of our <a href="http://borntolearn.mslearn.net/btl/b/weblog/archive/2010/07/12/calling-all-phone-developers-free-training-on-windows-phone-7.aspx">Windows Phone 7 Jumpstart</a> training.&nbsp; </p> <p>The JumpStart is a four part deep-dive into Windows Phone.&nbsp; The four sessions included:</p> <ol> <li>An Introduction to the Windows Phone Platform </li> <li>Game Building on the Windows Phone Platform </li> <li>Advanced Windows Phone Development </li> <li>Selling Your Windows Phone Solutions &amp; Wrap Up </li> </ol> <p>The reviews for the event were awesome.&nbsp; Thousands of people attended. Everybody liked the presenters and the content. </p> <p>You can download all the content for the JumpStart from <a href="http://borntolearn.mslearn.net/wp7/m/classresources/default.aspx">this MS Learning Website</a>.&nbsp; <br /><br />Below you can find links to the video recordings.&nbsp; <br />The recordings a little raw, they are captures of the sessions without edits, but the videos are great for learning Windows phone,&nbsp; they go through fast, and are a must-see companion to the demos and ppts..</p> <p>If you missed out, on these great sessions check the <a href="http://borntolearn.mslearn.net/">MS Learning blog</a> next month. I hear the events will be repeated often. </p> <p>Session one: Intro to the series and intro to Windows Phone platform:</p> <ul> <li>AM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072010&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072010&amp;pw=webcast</a> </li> <li>AM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-1&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-1&amp;pw=webcast</a> </li> <li>AM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-2&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-2&amp;pw=webcast</a>&nbsp; </li> </ul> <p>Session Two: Game building on Windows phone</p> <ul> <li>PM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-3&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-3&amp;pw=webcast</a> </li> <li>PM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-4&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-4&amp;pw=webcast</a> </li> <li>PM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-5&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072010-5&amp;pw=webcast</a> </li> </ul> <p>Session Three:&nbsp; Advanced Windows Phone development ( life cycle, state management, push, etc.. ) </p> <ul> <li>AM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072210&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072210&amp;pw=webcast</a> </li> <li>AM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-1&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-1&amp;pw=webcast</a> </li> <li>AM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-1-1&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-1-1&amp;pw=webcast</a> </li> </ul> <p>Session four: Selling your Windows Phone solution ( marketplace, A</p> <ul> <li>PM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-2&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-2&amp;pw=webcast</a> </li> <li>PM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-3&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-3&amp;pw=webcast</a> </li> <li>PM:&nbsp; <a href="https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-4&amp;pw=webcast">https://www.livemeeting.com/cc/microsoft/view?id=Win7072210-4&amp;pw=webcast</a> </li> </ul> <p>Happy Windows Phone coding.. </p><div style="clear:both;"></div><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10042002" width="1" height="1"> http://blogs.msdn.com/b/jaimer/archive/2010/07/23/video-recordings-for-first-windows-phone-7-jumpstart-event.aspx Jaime Rodriguez [MS] 2245 2010-07-23T21:17:00 Events and Delegates Under The Hood – Q&A In the comments from this morning’s post, Andrew raised two questions important enough that I wanted to answer them in a post, rather than in comments…. [In the original version of the posting] you had some code showing that you could use “=” with delegates but that you’d get a compile time error with the [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/V51KWCJXBeU/ Jesse Liberty [MS] 2244 2010-07-19T22:55:35 Events and Delegates Under The Hood – Reposted Many programmers come to Silverlight with little prior experience with C#, and thus conceptualize events as a response to an action that is “hooked up” using somewhat arbitrary syntax.  All of that is fine, until it isn’t, and so this post will dive a bit deeper into Delegates and Events as core aspects of .Net [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/q6a8wV9tQ98/ Jesse Liberty [MS] 2242 2010-07-19T19:13:16 Events and Delegates Under The Hood Many programmers come to Silverlight with little prior experience with C#, and thus conceptualize events as a response to an action that is “hooked up” using somewhat arbitrary syntax.&#160; All of that is fine, until it isn’t, and so this post will dive a bit deeper into Delegates and Events as core aspects of .Net [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/uRqVkhqtPWg/ Jesse Liberty [MS] 2241 2010-07-19T06:12:55 Teaching An Old Control New Tricks With Templates This is the fourth in a short series on Templates and DataValidation. [ First In Series&#160;&#160;&#160; Previous In Series ] You will remember that in the previous post in this small series, we created a new button template with a new appearance and new behavior for the “standard” view states.&#160; This button will be used [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/LGZDQj3BK-k/ Jesse Liberty [MS] 2234 2010-07-18T06:31:39 The Great Much More Signal, Much Less Noise Challenge of 2010 Starting today and running through the end of the year, I am challenging myself to post at least one useful, interesting or worthwhile entry every single day – (Yikes!) You are the judges. I will measure my success/failure on visits,  pageviews and subscribers I&#8217;ve also added per-post ratings so that you can indicate what you [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/LjE9rVYTBS0/ Jesse Liberty [MS] 2225 2010-07-17T19:59:37 Portland .NET User Group 3 Aug 2010 + Mole 2010 I’m very excited to announce that I’ll be speaking at the Portland .NET User Group on 3 Aug 2010.&#160; This will be my first time visiting Portland and I’m looking forward to it!&#160; This wide open night will close out with the first time unveiling of Mole 2010. Line of Business for WPF Departing from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1504&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/07/16/portland-net-user-group-3-aug-2010-mole-2010/ Karl Shifflett [MS] 2222 2010-07-17T04:29:28 The Disasters of Visual Design Tools <p> Many years ago &#x2014; about the time that visual design tools were being introduced into our programming environments &#x2014; I promised that I would never believe myself to be teaching programming if I were writing sentences like "Now drag the Button from the toolbox to the window." I am proud to say I have kept to that promise. </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/07/The-Disasters-of-Visual-Designer-Tools.html Charles Petzold 2216 2010-07-16T12:26:00 Templates, Visual State and Fun With Controls This is the third (if you count Sunday’s update!) in my short series on Templates and Data Validation. [ First In Series.  Previous In Series ] Today we’re going to create a templated  Button that changes the appearance and visual state behavior of the button. Changing the visual state behavior in this case means responding [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/3_fBBNcVOQo/ Jesse Liberty [MS] 2213 2010-07-15T20:41:59 Manipulation Events Update for the WP7 Beta <p> Always start with the good news: The good news is that the <i>Manipulation</i> events in the July beta of the Windows Phone 7 development tools no longer have the orientation problem I discussed in my blog entry <a href="http://www.charlespetzold.com/blog/2010/06/Basic-Manipulation-Event-Handling-in-Windows-Phone-7.html">Basic Manipulation Event Handling in Windows Phone 7</a> (at least with translation). You can flip the phone emulator sideways and translation coordinates don't need to be finagled. More good news: I am now able to get the emulator to recognize two fingers on my two touch screens, so I've been able to experiment with scaling as well as translation. </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/07/Manipulation-Events-Update-for-the-WP7-Beta.html Charles Petzold 2210 2010-07-14T20:07:57 Windows Phone 7 Development Tools Now in Beta <p> As of yesterday, Windows Phone 7 is in beta, which means there are <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c8496c2a-54d9-4b11-9491-a1bfaf32f2e3&amp;displaylang=en">updated development tools</a> to be downloaded and installed. </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/07/Windows-Phone-7-Development-Tools-Now-in-Beta.html Charles Petzold 2208 2010-07-13T22:41:11 Tips for uninstalling the Windows Phone Developer Tools CTPs and moving to beta <p>To install the Windows Phone Developer Tools beta, you will first need to uninstall the older CTP (if you had it installed). <br /> <br />The process is straight forward if you get the order right and don’t have other pre-release bits installed.&#160;&#160; All this means is </p> <ol> <li>You should uninstall the item named Microsoft Windows Phone Developer Tools CTP – ENU. That will chain the uninstall of other components. </li> </ol> <p>If you do run into issues (or you are reading this and already uninstalled in wrong order), the following blog posts have workarounds to the most common errors you will run into:</p> <ol> <li>You are trying to uninstall, but the software first wants to install something that is or was already installed.&#160; <br />Check <a href="http://blogs.msdn.com/prativen/archive/2010/07/13/windows-phone-developer-tools-beta-released.aspx">this post</a> </li> <li> You are getting an error installing the beta,&#160; need tips to check for incompatible components.&#160; Check <a href="http://blogs.msdn.com/astebner/archive/2010/07/12/10037442.aspx">this post</a> </li> <li>Your install failed in the middle, or you have uninstalled components out of order and you need some brute force uninstaller.&#160; Try <a href="http://blogs.msdn.com/astebner/archive/2009/04/10/9544320.aspx">this post</a> </li> </ol> <p>I hope that does it; if not please try the <a href="http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/threads">Windows Phone forums</a>.&#160; You can also email me, but responses are much more delayed than at the forums; we have a great team monitoring the forums. </p> <p>Happy Windows Phone coding. </p><div style="clear:both;"></div><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10037734" width="1" height="1"> http://blogs.msdn.com/b/jaimer/archive/2010/07/13/tips-for-uninstalling-the-windows-phone-developer-tools-ctps-and-moving-to-beta.aspx Jaime Rodriguez [MS] 2207 2010-07-13T21:19:19 Awarded Silverlight Cream’s Best Blog Post of 2010 I&#8217;m incredibly proud that Silverlight Cream (required reading for anyone interested in Silverlight) rated one of my blog posts #1 for 2010.    The pride results only from the fact  that Dave does such an incredible job every day culling the very best posts in the Silverlight eco-system. http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/iN8BEajoe5w/ Jesse Liberty [MS] 2205 2010-07-13T16:58:12 New Video: Introduction to Xaml In my new video An Introduction To Xaml, I recreate the form used in Adding Controls To An Application, but this time using Xaml rather than drag and drop. Part of the ongoing video series: Getting Started With Silverlight.   [30] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/UotByAX5KGo/ Jesse Liberty [MS] 2206 2010-07-13T16:32:36 Getting Request.Form Data Out of XDomainRequest In ASP.NET <p>I am using the XDomainRequest object in IE8 and IE9 to do cross domain posting.&nbsp; However, I hit an issue where I couldn't seem to get at the data I was posting: the Request.Form collection contained nothing yet I was clearly sending it. I then found this post:</p> <p><a href="http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx">http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx</a></p> <p>which states: "we restricted the content type to <em>text/plain</em> but didn&rsquo;t allow the caller to specify that the data was in <em>application/x-www-urlencoded</em> form. This is problematic because server-side frameworks (e.g. ASP, ASPNET, etc) will only automatically parse a request&rsquo;s fields into name-value pairs if the <em>x-www-urlencoded</em> content type is specified.</p> <p>To workaround this issue, server code that currently processes HTML Forms must be rewritten to manually parse the request body into name-value pairs when receiving requests from XDomainRequest objects. This makes adding support for the XDomainRequest object more difficult than it would be otherwise."</p> <p>Okay, so how does one do that? Well, turned to be pretty simple. I just had to access the Request.InputStream directly, as follows:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //set the header to support XDomainRequest</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Response.Headers.Add("Access-Control-Allow-Origin", "*");</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//now extract the data out of the stream</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.Stream str;</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String jsonContents;</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Int32 counter, strLen, strRead;</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Create a Stream object.</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;str = Request.InputStream;</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Find number of bytes in stream.</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strLen = Convert.ToInt32(str.Length);</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Create a byte array.</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;byte[] byteArray = new byte[strLen];</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Read stream into byte array.</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strRead = str.Read(byteArray, 0, strLen);</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Convert byte array to a text string.</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jsonContents = Encoding.UTF8.GetString(byteArray);</p> http://rhizohm.net/irhetoric/post/2010/07/12/Getting-RequestForm-Data-Out-of-XDomainRequest-In-ASPNET.aspx Karsten Januszewski [MS] 2204 2010-07-13T03:34:00 Eulogy The following is from the eulogy I gave for my mother in law. Posted here in the hope you might find some of it valuable. Speak no ill of the dead. It used to make me crazy to sit at a memorial service and listen to the Rabbi who had never met my father… or [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/malp_cLk4og/ Jesse Liberty [MS] 2201 2010-07-11T20:56:34 Styles (followup) Yesterday’s post did not include source, and left fleshing out the styles as an exercise… this quick follow-up will provide a link to the full code and a quick walkthrough of the styles I ended up creating. The tricky part is that there is not a single base class for the various controls we’re using [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/jIRjd0dGBJs/ Jesse Liberty [MS] 2200 2010-07-11T07:22:16 Visual State Manager A-Z This is the first of a multipart series on the Visual State Manager which will cover Styles Resources Templates Custom Controls Customizing data validation Let’s start with the form that is used in my Getting Started With Silverlight video: Adding Controls To An Application.  That video uses the design surface in Visual Studio 2010, and [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/-xdR49RgZfg/ Jesse Liberty [MS] 2199 2010-07-10T04:03:13 Serializing Request.ServerVariables to JSON: JavaScriptSerializer vs. DataContractJsonSerializer <p>I needed to serialize <strong>Request.ServerVariables</strong> to JSON.&nbsp; I tried both&nbsp;<span class="status-body"><span class="status-content"><span class="entry-content"> <strong>JavaScriptSerializer</strong> nor <strong>DataContractJsonSerializer</strong> without any luck.&nbsp; But I thought&nbsp;<span class="status-body"><span class="status-content"><span class="entry-content">both would work, as <strong>Request.ServerVariables</strong> is of type <strong>NameValueCollection</strong> and the docs on MSDN state that both serialization engines support dictionaries. The solution? Convert (manually) the <strong>NameValueCollection</strong> into a dictionary.</span></span></span></span></span></span></p> <p><span class="status-body"><span class="status-content"><span class="entry-content"><span class="status-body"><span class="status-content"><span class="entry-content">Here's the code:</span></span></span></span></span></span></p> <p><span class="status-body"><span class="status-content"></span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&lt;string,string&gt; d = new Dictionary&lt;string,string&gt;();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (string s in Request.ServerVariables.AllKeys)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d.Add(s, Request.ServerVariables[s]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //DataContractJsonSerializer<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataContractJsonSerializer serverVariablesSerializer = new DataContractJsonSerializer(typeof(Dictionary&lt;string,string&gt;));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemoryStream ms = new MemoryStream();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; serverVariablesSerializer.WriteObject(ms, d); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string json = Encoding.Default.GetString(ms.ToArray());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.WriteLine(json);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //JavaScriptSerializer<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JavaScriptSerializer serverVariablesSerializer2 = new JavaScriptSerializer();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string json2 = serverVariablesSerializer2.Serialize(d);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.WriteLine(json2);</p> <p>What's interesting is that the output is different between the two serialization engines. <strong>JavaScriptSerializer</strong> is smart enough to turn the key into the key in JSON, whereas <strong>DataContractJsonSerializer</strong> creates a key called "key" with the value of the key and then a key called "value" with the value of the value. Kind of annoying. The winner? <strong>JavaScriptSerializer</strong></p> <p> <p>Here's the output BTW:</p> <p><strong>DataContractJsonSerializer:</strong> [{"Key":"ALL_HTTP","Value":"HTTP_CONNECTION:Keep-Alive\u000d\u000aHTTP_ACCEPT:*\/*\u000d\u000aHTTP_ACCEPT_ENCODING:gzip, deflate\u000d\u000aHTTP_ACCEPT_LANGUAGE:en-us\u000d\u000aHTTP_COOKIE:comment=name=b&amp;email=b@b.com&amp;url=&amp;country=us; WT_FPC=id=71.231.143.146-177222816.30061129:lv=1277910617997:ss=1277910147666\u000d\u000aHTTP_HOST:localhost:4135\u000d\u000aHTTP_USER_AGENT:Mozilla\/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident\/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)\u000d\u000a"},{"Key":"ALL_RAW","Value":"Connection: Keep-Alive\u000d\u000aAccept: *\/*\u000d\u000aAccept-Encoding: gzip, deflate\u000d\u000aAccept-Language: en-us\u000d\u000aCookie: comment=name=b&amp;email=b@b.com&amp;url=&amp;country=us; WT_FPC=id=71.231.143.146-177222816.30061129:lv=1277910617997:ss=1277910147666\u000d\u000aHost: localhost:4135\u000d\u000aUser-Agent: Mozilla\/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident\/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)\u000d\u000a"},{"Key":"APPL_MD_PATH","Value":""},{"Key":"APPL_PHYSICAL_PATH","Value":"C:\\stuff\\WebApplication1\\WebApplication1\\"},{"Key":"AUTH_TYPE","Value":"NTLM"},{"Key":"AUTH_USER","Value":"REDMOND\\karstenj"},{"Key":"AUTH_PASSWORD","Value":""},{"Key":"LOGON_USER","Value":"REDMOND\\karstenj"},{"Key":"REMOTE_USER","Value":"REDMOND\\karstenj"},{"Key":"CERT_COOKIE","Value":""},{"Key":"CERT_FLAGS","Value":""},{"Key":"CERT_ISSUER","Value":""},{"Key":"CERT_KEYSIZE","Value":""},{"Key":"CERT_SECRETKEYSIZE","Value":""},{"Key":"CERT_SERIALNUMBER","Value":""},{"Key":"CERT_SERVER_ISSUER","Value":""},{"Key":"CERT_SERVER_SUBJECT","Value":""},{"Key":"CERT_SUBJECT","Value":""},{"Key":"CONTENT_LENGTH","Value":"0"},{"Key":"CONTENT_TYPE","Value":""},{"Key":"GATEWAY_INTERFACE","Value":""},{"Key":"HTTPS","Value":""},{"Key":"HTTPS_KEYSIZE","Value":""},{"Key":"HTTPS_SECRETKEYSIZE","Value":""},{"Key":"HTTPS_SERVER_ISSUER","Value":""},{"Key":"HTTPS_SERVER_SUBJECT","Value":""},{"Key":"INSTANCE_ID","Value":""},{"Key":"INSTANCE_META_PATH","Value":""},{"Key":"LOCAL_ADDR","Value":"127.0.0.1"},{"Key":"PATH_INFO","Value":"\/Default.aspx"},{"Key":"PATH_TRANSLATED","Value":"C:\\stuff\\WebApplication1\\WebApplication1\\Default.aspx"},{"Key":"QUERY_STRING","Value":""},{"Key":"REMOTE_ADDR","Value":"127.0.0.1"},{"Key":"REMOTE_HOST","Value":"127.0.0.1"},{"Key":"REMOTE_PORT","Value":""},{"Key":"REQUEST_METHOD","Value":"GET"},{"Key":"SCRIPT_NAME","Value":"\/Default.aspx"},{"Key":"SERVER_NAME","Value":"localhost"},{"Key":"SERVER_PORT","Value":"4135"},{"Key":"SERVER_PORT_SECURE","Value":"0"},{"Key":"SERVER_PROTOCOL","Value":"HTTP\/1.1"},{"Key":"SERVER_SOFTWARE","Value":""},{"Key":"URL","Value":"\/Default.aspx"},{"Key":"HTTP_CONNECTION","Value":"Keep-Alive"},{"Key":"HTTP_ACCEPT","Value":"*\/*"},{"Key":"HTTP_ACCEPT_ENCODING","Value":"gzip, deflate"},{"Key":"HTTP_ACCEPT_LANGUAGE","Value":"en-us"},{"Key":"HTTP_COOKIE","Value":"comment=name=b&amp;email=b@b.com&amp;url=&amp;country=us; WT_FPC=id=71.231.143.146-177222816.30061129:lv=1277910617997:ss=1277910147666"},{"Key":"HTTP_HOST","Value":"localhost:4135"},{"Key":"HTTP_USER_AGENT","Value":"Mozilla\/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident\/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)"}]</p> <p><strong>JavaScriptSerializer:</strong> {"ALL_HTTP":"HTTP_CONNECTION:Keep-Alive\r\nHTTP_ACCEPT:*/*\r\nHTTP_ACCEPT_ENCODING:gzip, deflate\r\nHTTP_ACCEPT_LANGUAGE:en-us\r\nHTTP_COOKIE:comment=name=b&amp;email=b@b.com&amp;url=&amp;country=us; WT_FPC=id=71.231.143.146-177222816.30061129:lv=1277910617997:ss=1277910147666\r\nHTTP_HOST:localhost:4135\r\nHTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)\r\n","ALL_RAW":"Connection: Keep-Alive\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: en-us\r\nCookie: comment=name=b&amp;email=b@b.com&amp;url=&amp;country=us; WT_FPC=id=71.231.143.146-177222816.30061129:lv=1277910617997:ss=1277910147666\r\nHost: localhost:4135\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)\r\n","APPL_MD_PATH":"","APPL_PHYSICAL_PATH":"C:\\stuff\\WebApplication1\\WebApplication1\\","AUTH_TYPE":"NTLM","AUTH_USER":"REDMOND\\karstenj","AUTH_PASSWORD":"","LOGON_USER":"REDMOND\\karstenj","REMOTE_USER":"REDMOND\\karstenj","CERT_COOKIE":"","CERT_FLAGS":"","CERT_ISSUER":"","CERT_KEYSIZE":"","CERT_SECRETKEYSIZE":"","CERT_SERIALNUMBER":"","CERT_SERVER_ISSUER":"","CERT_SERVER_SUBJECT":"","CERT_SUBJECT":"","CONTENT_LENGTH":"0","CONTENT_TYPE":"","GATEWAY_INTERFACE":"","HTTPS":"","HTTPS_KEYSIZE":"","HTTPS_SECRETKEYSIZE":"","HTTPS_SERVER_ISSUER":"","HTTPS_SERVER_SUBJECT":"","INSTANCE_ID":"","INSTANCE_META_PATH":"","LOCAL_ADDR":"127.0.0.1","PATH_INFO":"/Default.aspx","PATH_TRANSLATED":"C:\\stuff\\WebApplication1\\WebApplication1\\Default.aspx","QUERY_STRING":"","REMOTE_ADDR":"127.0.0.1","REMOTE_HOST":"127.0.0.1","REMOTE_PORT":"","REQUEST_METHOD":"GET","SCRIPT_NAME":"/Default.aspx","SERVER_NAME":"localhost","SERVER_PORT":"4135","SERVER_PORT_SECURE":"0","SERVER_PROTOCOL":"HTTP/1.1","SERVER_SOFTWARE":"","URL":"/Default.aspx","HTTP_CONNECTION":"Keep-Alive","HTTP_ACCEPT":"*/*","HTTP_ACCEPT_ENCODING":"gzip, deflate","HTTP_ACCEPT_LANGUAGE":"en-us","HTTP_COOKIE":"comment=name=b&amp;email=b@b.com&amp;url=&amp;country=us; WT_FPC=id=71.231.143.146-177222816.30061129:lv=1277910617997:ss=1277910147666","HTTP_HOST":"localhost:4135","HTTP_USER_AGENT":"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)"}</p> </p> http://rhizohm.net/irhetoric/post/2010/07/07/Serializing-RequestServerVariables-to-JSON-JavaScriptSerializer-vs-DataContractJsonSerializer.aspx Karsten Januszewski [MS] 2197 2010-07-07T21:06:00 Non-Linear Navigation in Silverlight 4 In the last Seattle Silverlight User Group meeting I spoke about Non-Linear Navigation in Silverlight.&#160; This blog post is a proof-of-concept for Non-Linear Navigation in Silverlight 4 Navigation Applications.&#160; When I was first exploring this, I did not use the Navigation Application template, instead I implemented Non-Linear Navigation similar to what I did in BBQ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1501&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/07/07/non-linear-navigation-in-silverlight-4/ Karl Shifflett [MS] 2198 2010-07-07T19:25:00 XAML Compliance Suite V1 <p><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">Generally, when theres an open spec format, theres usually a set of tests that ensure that the spec is being followed right. As as example, the Acid tests&nbsp;help in deterning&nbsp;the support of web standards in different web browsers. So when it came to XAML, we decided that we should have a basic set of tests that can be used to determine whether the parser implementation&nbsp;is compliant with the XAML spec. You can find the latest XAML spec at (</span></span><a href="http://msdn.microsoft.com/en-us/library/ff629155(PROT.10).aspx"><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">LINK</span></span></a><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">)</span></span></p> <p><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">So here we have it, V1 of the XAML Compliance suite of tests. The suite&nbsp;<span style="font-size: small;">consists of two parts: a custom type library and a collection of xaml files that use those types.<span style="mso-spacerun: yes;">&nbsp;&nbsp;The types are self verifiable - so using the library would need users to have a simple function that exercises their parser with the xaml files. A simple loader for the System.Xaml parser is included in the project as a sample. Since the types are CLR based they can easily be used with other parsers without needing a dependency on WPF.</span></span></span></span></p> <p><span style="font-size: small;"><span style="mso-spacerun: yes;"><span style="font-family: arial,helvetica,sans-serif;">The sample loader has the following usage: </span></span></span></p> <p><span style="font-size: small;"><span style="mso-spacerun: yes"></span></span><span style="font-size: small;"><span style="mso-spacerun: yes;"><span style="font-family: arial,helvetica,sans-serif;">Usage: SystemXamlLoader.exe XamlFileRepositoryPath TypesDll LogOnlyFailures<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XamlFileRepositoryPath: Path to directory of test xaml files<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TypesDll: Dll containing custom types to load.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOnlyFailures: True|False. Defaults to True</span></span></span></p> <p><span style="font-size: small;"><span style="mso-spacerun: yes;"><span style="font-family: arial,helvetica,sans-serif;">E.g: SystemXamlLoader.exe Xaml&nbsp;Xaml.Test.dll false<br /></span></span></span></p> <p><span style="font-size: small;"><span style="font-family: Calibri;"> <p><span style="mso-spacerun: yes;"><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">The zipped up suite is <a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-10-03-24-51/XamlComplianceSuite.zip">attached</a></span></span></span></p> </span></span></p> <div align="center" class="shareblock"><strong>Share this post<br /></strong><a target="_blank" href="mailto:?body=Thought you might like this: http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx&amp;subject=XAML Compliance Suite" title="Share via Email"><img src="http://blogs.msdn.com/photos/llester/images/1445315/original.aspx" border="0" /></a> <a title="Submit to digg.com" target="_blank" href="http://www.digg.com/submit?url=http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx&amp;phase=2&amp;title=XAML Compliance Suite"><img src="http://blogs.msdn.com/photos/llester/images/1445312/original.aspx" border="0" /></a> <a target="_blank" href="http://www.facebook.com/sharer.php?u=http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx&amp;t=XAML Compliance Suite" title="Facebook"><img src="http://blogs.msdn.com/photos/llester/images/9973564/original.aspx" border="0" /></a> <a title="Submit to del.icio.us" target="_blank" href="http://del.icio.us/post?url=http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx&amp;title=XAML Compliance Suite"><img src="http://blogs.msdn.com/photos/llester/images/1445311/original.aspx" border="0" /></a> <a target="_blank" href="http://www.twitter.com/home?status=Currently+Reading:+http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx" title="Share link on Twitter"><img src="http://blogs.msdn.com/photos/llester/images/9973581/original.aspx" border="0" /></a> <a target="_blank" href="http://dotnetshoutout.com/Submit?url=http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx" title="Submit to .NetShoutOut"><img src="http://blogs.msdn.com/photos/llester/images/9973600/original.aspx" border="0" /></a> <a title="Submit to dotnetkicks.com" target="_blank" href="http://www.dotnetkicks.com/submit/?url=http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx&amp;title=XAML Compliance Suite"><img src="http://blogs.msdn.com/photos/llester/images/1445375/original.aspx" border="0" /></a> <a title="Stumble It" target="_blank" href="http://www.stumbleupon.com/submit?url=http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx&amp;title=XAML Compliance Suite"><img src="http://blogs.msdn.com/photos/llester/images/9191709/original.aspx" border="0" /></a> </div> <p>&nbsp;</p><div style="clear:both;"></div><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10032451" width="1" height="1"> http://blogs.msdn.com/b/llobo/archive/2010/07/07/xaml-compliance-suite-v1.aspx Lester Lobo 2196 2010-07-07T15:28:00 XAML Power Toys for Visual Studio 2010 for Cider version 2.1 Silverlight 4 Support I have just updated XAML Power Toys for Visual Studio 2010 for Cider to version 2.1 adding support for Silverlight 4. Please Note I have two XAML Power Toys products on my blog.&#160; They are not the same.&#160; Get both, you’ll be glad you did.&#160; The first one is for working in the XAML Editor [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1494&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/07/07/xaml-power-toys-for-visual-studio-2010-for-cider-version-2-1-silverlight-4-support/ Karl Shifflett [MS] 2195 2010-07-07T12:51:09 XAML Power Toys for Visual Studio 2010 version 6.1 Silverlight 4 Support I have just updated XAML Power Toys for Visual Studio 2010 to version 6.1 adding support for Silverlight 4. New Features and Fixes Added support for Silverlight 4 Corrected ViewModel creator spit If you remove the CommandParameter type in the Command Creation Window, the spit will no longer add the CommandParameter type to the RelayCommand [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1491&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/07/07/xaml-power-toys-for-visual-studio-2010-version-6-1-silverlight-4-support/ Karl Shifflett [MS] 2194 2010-07-07T11:28:28 Using Stringify With the New window.msPerformance in Internet Explorer 9 <p>I've been playing with the new <strong>window.msPerformance</strong> that's part of IE9 as explained in this blog post: <a href="http://blogs.msdn.com/b/ie/archive/2010/06/28/measuring-web-page-performance.aspx">http://blogs.msdn.com/b/ie/archive/2010/06/28/measuring-web-page-performance.aspx</a>. Of course, the main thing you want to do is capture this data. The blog post mentions that you can use the stringify method to serialize the object to JSON and then send the diagnostics back to the server.&nbsp; Well, I tried this with no luck. Here's what my code looked like:</p> <p style="padding-left: 30px;">&nbsp;&nbsp; &lt;script type="text/javascript" &gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function test() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (window.msPerformance != null) {</p> <p style="padding-left: 30px;"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var json = JSON.stringify(window.msPerformance.timing);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(window.msPerformance.timing);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(json);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&lt;/script&gt;</p> <p>Even though the performance object was populated, the serialization to JSON failed.</p> <p>I did some digging around and learned that the native JSON method in IE9 doesn't successfully stringify native objects, like anything hanging off <strong>window</strong> or <strong>document</strong>.&nbsp; However, I was able to work around this by using Crockford's JSON class from here: <a href="http://www.json.org/js.html">http://www.json.org/js.html</a>.&nbsp; The one thing I had to do was to change the prototype to JSON2 so that the browser's native JSON prototype wasn't called. Then it worked!</p> http://rhizohm.net/irhetoric/post/2010/07/06/Using-Stringify-With-the-New-windowmsPerformance-in-Internet-Explorer-9.aspx Karsten Januszewski [MS] 2193 2010-07-06T21:29:00 Sample Data in the WPF and Silverlight Designer I just posted a comprehensive article on Sample Data in the Visual Studio 2010 WPF and Silverlight Designer here. This article is scenario based and fully explains sample data in WPF and Silverlight. It includes code sample in C# and VB.NET. Have a great day, Just a grain of sand on the worlds beaches. Filed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1483&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/06/30/sample-data-in-the-wpf-and-silverlight-designer/ Karl Shifflett [MS] 2190 2010-07-01T03:55:57 For Wendy Friedlander <p> Two summers ago I was working three days a week on a large WPF application at a company in New York City, and that's where I met <a href="http://wundasworld.blogspot.com/">Wendy Friedlander</a>. Wendy brought several important skills to the project. Whereas I functioned as little more than a coder, Wendy revealed herself as a talented WPF programmer and much more besides. Her extensive practical experience in agile development practices, pair programming, and test-driven development helped the project enormously, and introduced me to modern team development strategies. Wendy was also one of the friendliest people I'd ever met and a joy to work with. </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/06/For-Wendy-Friedlander.html Charles Petzold 2189 2010-06-30T21:29:20 Seattle Silverlight User Group – Windows Phone 7 Summer Series The Seattle Silverlight User Group meets at the Redmond Campus building 40/41 Cafeteria the first Wednesday of every month. On Wednesday, 7 July we begin the Summer Series on Windows Phone 7. With the help of Jaime Rodriquez and other Microsoft folks we will be getting down and dirty with Windows Phone 7 and getting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1482&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/06/30/seattle-silverlight-user-group-windows-phone-7-summer-series/ Karl Shifflett [MS] 2188 2010-06-30T07:34:21 PivotViewer Released! Run, do not walk to Pete Brown’s blog and read about the new PivotViewer control. This is a very cool control just released by LiveLabs and that is fully supported in the new PivotViewer learning section on Silverlight.net. The home page provides links to the code you need, three overview videos and, at the bottom [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/A4ydXShQRaQ/ Jesse Liberty [MS] 2178 2010-06-29T23:27:06 Migrating apps from Windows Phone April CTP Refresh to the beta build <p><br />There were a good number of breaking changes and new features introduced in the &ldquo;beta&rdquo; release of the Windows Phone Developer Tools. <br />Going forward from beta to RTM; the number of breaking changes will be minimal, so let&rsquo;s just &ldquo;buckle up&rdquo; and migrate our code this once. <br />The migration is a lot easier than it sounds. I will first walk through the obvious breaking changes that the compiler will catch, and then share tips and workarounds in some of that &lsquo;missing&rsquo; stuff that the compiler will miss.&nbsp; <br />Once you have gotten through this, don&rsquo;t forget to read my post on the new features in the beta release so you can start taking advantage of these. <br /><br /><strong>Breaking changes: </strong></p> <ol sizset="0" sizcache="1"> <li><strong>Namespaces and assembly changes: <br /></strong>The following assemblies were removed, and merged into a single &ldquo;Microsoft.Phone&rdquo; assembly: <br />Microsoft.Phone.Controls <br />Microsoft.Phone.Controls.Navigation <br />Microsoft.Phone.Controls.WebBrowser <br />Microsoft.Phone.Controls.WebBrowserInterop <br />Microsoft.Phone.Shell <br />Microsoft.Phone.Notification <br />Microsoft.Phone.Execution <br />Microsoft.Phone.Info <br />Microsoft.Phone.Tasks <br />Microsoft.Devices <br /><em>To fix: change all your project references and all your namespaces declarations (xmlns) in XAML. See MigrationTips.1 below for details on namespaces.<br /></em></li> <li><strong>System.Device.Location assembly was merged into System.Device assembly </strong><em><br />To fix: change assembly references that were pointing to System.Device.Location and point them to System.Device assembly. <br /></em></li> <li><strong>Microsoft.Devices assembly was removed; the classes in this assembly were moved to Microsoft.Phone assembly.&nbsp; Some of the classes changed namespaces, but not all. <br /></strong><em>To fix: change assembly references and reference Microsoft.Phone assembly. <br /></em></li> <li><strong>Application.Resources have been removed from App.xaml and templates have been changed </strong><em><br />To fix: you will need to remove these from your own App.xaml. Can&rsquo;t leave them in because it would break theming; also, there are breaking changes (controls removed) that would prevent your app from running if you do not get rid of the resources. See below on MigrationTips.2 for details on what to remove and how. <br /></em></li> <li><strong>ToggleControlSwitch and ToggleControlButton have been removed. <br /></strong><em>To fix: You should&nbsp; use ToggleButton and copy the template from RC version of ToggleControlSwitch. You will then need to add the touch gesture. Wait for a sample for this. I will post one soon. <br /></em></li> <li><em><strong>ListView and ListView Item were removed <br /></strong><em>To fix</em>: Use ListBox and a Template that matches the old ListViewItem template. </em></li> <li><strong>Effects have been removed from the platform, this will be plan of record for v1 (the feature might come back later). <br /></strong>In earlier builds, we had DropShadow, and Blur bitmap effects.&nbsp; Unfortunately, these have been removed. <br />Right now, your XAML is not breaking, but the usage of the effects is turning into a no-op. <blockquote> <p><em><em>To fix</em>: You should just remove the references to effects from XAML and code. You can use graphics (e.g. gradients for dropshadows) to try to get similar look &amp; feel. Not exactly the same, but best workaround I can think of until Microsoft brings these back in a future version of the platform. </em></p> </blockquote> </li> <li sizset="0" sizcache="1"><strong>A few classes were renamed or moved namespaces:&nbsp; <br /></strong> <table cellpadding="2" cellspacing="0" border="1" style="width: 769px; table-layout: fixed; word-break: break-all;"> <tbody> <tr> <td width="79" valign="top"><strong>Type </strong></td> <td width="255" valign="top"><strong>Old </strong></td> <td width="288" valign="top"><strong>New</strong></td> <td width="145" valign="top"><strong>New assembly <br />(if changed)</strong></td> </tr> <tr> <td width="79" valign="top">namespace</td> <td width="255" valign="top">Microsoft.Devices.NetworkInformation</td> <td width="288" valign="top">Microsoft.Phone.Net.NetworkInformation</td> <td width="145" valign="top">Microsoft.Phone.dll</td> </tr> <tr> <td width="79" valign="top">namespace</td> <td width="255" valign="top">Microsoft.Phone.License</td> <td width="288" valign="top">Microsoft.Phone.Marketplace</td> <td width="145" valign="top">Microsoft.Phone.dll </td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">Microsoft.Phone.Controls.NavigatedEventArgs </td> <td width="288" valign="top">System.Windows.Navigation.NavigationEventArgs</td> <td width="145" valign="top">System.Windows.dll </td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">Microsoft.Phone.Navigation.PhoneNavigationEventArgs</td> <td width="288" valign="top">System.Windows.Navigation.NavigationEventArgs</td> <td width="145" valign="top">System.Windows.dll </td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">AccelerometerSensor</td> <td width="288" valign="top">Accelerometer</td> <td width="145" valign="top">&nbsp;</td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">AccelerometerReadingAsyncEventArgs</td> <td width="288" valign="top">AccelerometerReadingEventArgs</td> <td width="145" valign="top">&nbsp;</td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">AccelerometerStartFailedException</td> <td width="288" valign="top">AccelerometerFailedException</td> <td width="145" valign="top">&nbsp;</td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">WindowsPhoneEvents</td> <td width="288" valign="top">Microsoft.Phone.Shell.PhoneApplicationService</td> <td width="145" valign="top">Microsoft.Phone.dll </td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">Microsoft.Phone.License.LicenseInfo</td> <td width="288" valign="top">Microsoft.Phone.Marketplace.LicenseInformation</td> <td width="145" valign="top">Microsoft.Phone.dll</td> </tr> <tr> <td width="79" valign="top">enum</td> <td width="255" valign="top">Microsoft.Phone.Shell.DownloadInterval</td> <td width="288" valign="top">Microsoft.Phone.Shell.UpdateInterval</td> <td width="145" valign="top">Microsoft.Phone.dll </td> </tr> <tr> <td width="79" valign="top">enum</td> <td width="255" valign="top">Microsoft.Phone.Shell.DownloadRecurrence</td> <td width="288" valign="top">Microsoft.Phone.Shell.UpdateRecurrence</td> <td width="145" valign="top">Microsoft.Phone.dll</td> </tr> <tr> <td width="79" valign="top">class</td> <td width="255" valign="top">NotificationChannelExceptionEventArgs</td> <td width="288" valign="top">NotificationChannelErrorEventArgs</td> <td width="145" valign="top">Microsoft.Phone.dll</td> </tr> </tbody> </table> <p>To fix: simply replace the namespace and/or class name and reference the new assembly (if applicable)</p> </li> <li><strong>Minor changes were made to the WMAppManifest.xml file <br /></strong><ol> <li>XNA projects used to have an PlaceHolderString="Default task" on the WMAppManifiest.xml&nbsp; this XML attribute is not longer valid. <br />&nbsp;<em>Fix: remove the attribute from manifest. . </em></li> <li>In the App element, the Genre attribute changed from NormalApp to Apps.Normal </li> <li>In the App element, the RuntimeType attribute changed from SilverLight to Silverlight.&nbsp;&nbsp; {notice the case difference on the L} </li> </ol></li> <li><strong>System.Reactive namespace was moved to Microsoft.Phone.Reactive and there is a new assembly called Microsoft.Phone.Reactive.dll <br /></strong>The System.Concurrency and System.Disposable namespaces are now on this assembly. </li> <li><strong>Removed ManipulationCompletedEventArgs.IsTapEvent property</strong> <br /><em>To fix: remove references to the property.&nbsp; You can use OnClick handlers. <br /></em></li> <li><strong>Choosers API are no longer returning on OnChooserReturn; they now have instance based events. <br /></strong>The PhoneNumberChooserTask and PhotoChooserTask used to always return on an override on the Page hosting. They now have events that the task exposes and you can add the handler and listen to the return from any class you like.&nbsp; The tasks have a Completed event you can listen to. </li> <li><strong>Other miscellaneous changes you might run into: <br /></strong><ol> <li>The ApplicationBarIconButton has a new Text property and it can't be empty.. whitespace does not work either. <br />You must enter something; old projects will get an InvalidOperationException with message of &ldquo;Text cannot be empty&rdquo; if you try to use the buttons with no text.&nbsp;&nbsp; <br /><em><em>To fix</em>:&nbsp; enter some text for your button. <br /></em></li> <li>OnOrientationChanging virtual method on PhoneApplicationPage has been removed; now you just get OnOrientationChanged <br /><em>To fix</em>: remove references to Deprecated event </li> <li>Signature change on PhoneApplicationPage class <br />override void OnNavigatedFrom(Microsoft.Phone.Navigation.PhoneNavigationEventArgs e)&nbsp; becomes <br />override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e); </li> <li>AccelerometerReadingEventArgs was refactored and it no longer has a Value property wrapping the sensor data; you can now get to the X, Y, Z properties directly. </li> <li>I already mentioned that WindowsPhoneEvents class was replaced by&nbsp; PhoneApplicationService class.&nbsp; <br />The events in these classes were also renamed from Paused to Deactivated and Resume to Activated. </li> <li>System.Windows.Browser.dll&nbsp; has been finally removed. You should not have been using this assembly (since nothing worked, it was not supported).&nbsp;&nbsp; The common reasons to look for this assembly included: <br />HttpUtility class, which is in System.Windows.dll in the System.Net namespace. <br />Interop between browser and Javascript.&nbsp; If you are needing that, use the WebBrowser control and the ScriptNotify and </li> <li>Changed PhoneApplicationPage.ApplicationBar property from type ApplicationBar to IApplicationBar. <br />Your old code should still work, but there might be a cast needed pending how you coded it. </li> <li>ManipulationDeltaEventArgs.CumulativeManipulation.Translation, ManipulationDeltaEventArgs.DeltaManipulation.Translation, and ManipulationDeltaEventArgs.TotalManipulation.Translation are now only populated when the user has moved certain number of pixels from original contact point. </li> <li>Scale property in ManipulationDeltaEventArgs.DeltaManipulation and ManipulationDeltaeventArgs.TotalManipulation has been changed to return 1 when there is no changes (instead of returning 0 in CTP Refresh); this mostly means you can go through your code, and remove the check you would have had to add before where you were detecting 0.0 and throwing it away. </li> </ol></li> <li><strong>A few push notification changes (this list is best explained via sample,&nbsp; the new TrainingKit has a great hands-on lab that will walk you through these changes ) </strong><ol> <li>Microsoft.Phone.Notification went away, reference Microsoft.Phone </li> <li>Channel.ExceptionOccurred event is now Channel.ErrorOccurred </li> <li>HttpNotificationChannel.BindToShellNotification is now HttpNotificationChannel.BindToShellTile () </li> <li>NotificationChannelExistsException has been removed.&nbsp; You can now check if HttpNotificationChannel.IsShellTileBound before you bind to Shell </li> <li>ShellEntryPoint class is gone. We not use standard Uris </li> <li>HttpNotificationChannel.ShellNotificationReceived is now HttpNoficationChannel.ShellToastNotificationReceived&nbsp; </li> </ol></li> </ol> <p><strong>Steps for migrating your code (referenced above as MigrationTips.X ) : </strong></p> <ol sizset="1" sizcache="1"> <li sizset="1" sizcache="1"><strong>Fix all project references.&nbsp; </strong><ol sizset="1" sizcache="1"> <li>Remove references to Microsoft.Phone.Controls, Microsoft.Phone.Controls.Navigation, Microsoft.Phone.Controls.WebBrowser, Microsoft.Controls.WebBrowser.interop </li> <li>Add a reference to Microsoft.Phone assembly </li> <li sizset="1" sizcache="1">Do a global search and replace for the xmlns declarations. For example: <br /> <table cellpadding="2" cellspacing="0" border="1" style="width: 700px; table-layout: fixed; word-break: break-all;"> <tbody> <tr> <td valign="top">Search for </td> <td valign="top">Replace with</td> </tr> <tr> <td valign="top">clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation</td> <td valign="top">clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone</td> </tr> <tr> <td valign="top">clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.WebBrowser</td> <td valign="top">clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone</td> </tr> <tr> <td valign="top">clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone.Shell</td> <td valign="top">clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone</td> </tr> <tr> <td valign="top">clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls</td> <td valign="top">clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone</td> </tr> <tr> <td valign="top">&nbsp;</td> <td valign="top">&nbsp;</td> </tr> </tbody> </table> <br />The list above is not all inclusive, but it is the most common one and shows you the &ldquo;pattern&rdquo; to use: don&rsquo;t replace the whole xmlns declaration, just replace the clr-namespace strings, and your code will be easier to migrate.&nbsp; The search above can be applied to just XAML files, making it slightly quicker to replace all. </li> </ol></li> <li><strong>Fixing themes and App.xaml resources issues:</strong> <br />Assuming you had not added your own resources, <ol> <li>open App.xaml and remove all the Application.Resources </li> <li>Do a global find/replace for following strings, these are resources that were in App.xaml but are not automatically inserted by the run-time. Most of these are used by the default Mainpage.xaml that every new project includes: </li> </ol></li> <li sizset="2" sizcache="1"> <blockquote sizset="2" sizcache="1"> <table cellpadding="2" cellspacing="0" border="1" style="width: 639px; table-layout: fixed; word-break: break-all;"> <tbody> <tr> <td width="318" valign="top">Search for </td> <td width="319" valign="top">Replace with: </td> </tr> <tr> <td width="318" valign="top">PhoneTextPageTitle1Style&nbsp; </td> <td width="319" valign="top">PhoneTextNormalStyle </td> </tr> <tr> <td width="318" valign="top">PhoneTextPageTitle2Style</td> <td width="319" valign="top">PhoneTextTitle1Style</td> </tr> <tr> <td width="318" valign="top">PhoneTextApplicationNameStyle </td> <td width="319" valign="top">PhoneTextNormalStyle </td> </tr> <tr> <td width="318" valign="top">PhoneTextTitleNameStyle </td> <td width="319" valign="top">PhoneTextTitle1Style</td> </tr> </tbody> </table> </blockquote> </li> <li><strong>Fixing your WMAppManifest.xml file </strong><ol> <li>The easiest way to fix your manifest is to create a new empty project with same name than your existing one, and copy the whole WMAppManifest to your project.&nbsp; You can also copy a few of the attributes, elements. These are the commone ones to watch out for: </li> <li>XNA projects used to have an PlaceHolderString="Default task" on the WMAppManifiest.xml&nbsp; this XML attribute is not longer valid, please remove it. </li> <li>In the App element, the Genre attribute changed from NormalApp to Apps.Normal </li> <li>In the App element, the RuntimeType attribute changed from SilverLight to Silverlight.&nbsp;&nbsp; {notice the case difference on the L} </li> <li>Do clean-up or update the auto-generated metadata on your WMAppManifest, including App.Author, App.Description and App.Publisher </li> <li>If you do not have capabilities (maybe you were not using refresh but MIX build) copy the whole&nbsp; &lt;App&gt;&lt;Capabilities&gt; element from the empty project to yours </li> <li>&lt;Tasks&gt; collection has a &lt;DefaultTask&gt; element with a new NavigationPage attribute.&nbsp; In previous builds this was set via code in App.xaml via the &lt;Application.RootVisual&gt; you can use either. They both work, just make sure you have one or the other approach (and not both) </li> </ol></li> <li><strong>Remove old workarounds:</strong> <ol> <li>Remove checking for 0 == ManipulationDeltaEventArgs.*.Scale. </li> <li>TransformToVisual and FindElementsInHostCoordinates. Orientation has been fixed and now we rotate the application frame, so these workarounds are no longer needed. </li> <li>You can now reference signed assemblies again, so if you had used the workaround to unsign them, you can remove it again. </li> </ol></li> </ol> <p>Closing Advise/asks: <br /><strong>Please share back your experiences and tips!!&nbsp;&nbsp;&nbsp; </strong>I know this document is not 100% comprehensive. If you run into one change that I missed or get stuck along the way, please email me directly [via email blog author on the sidebar column] so we can update and improve this document. </p> <p><strong>Don&rsquo;t forget to read the </strong><a href="http://go.microsoft.com/fwlink/?LinkId=194469">release notes</a><strong>. </strong>This document overlaps with some of the content in the release notes, but I focused on migration, so there are other tips and known issues there that will be useful to you; please take a look at the release notes.&nbsp; </p> <p>Happy Windows Phone coding! </p><div style="clear:both;"></div><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10031347" width="1" height="1"> http://blogs.msdn.com/b/jaimer/archive/2010/06/28/migrating-apps-from-windows-phone-ctps-to-the-beta-build.aspx Jaime Rodriguez [MS] 2202 2010-06-28T20:00:00 The Archivist Is Live! <p>Well, the project I've been working on for quite a while just went live to the world: The Archivist at <a href="http://archivist.visitmix.com">http://archivist.visitmix.com</a>. Go give it a whirl and let me know what you think. The intro article is here: <a href="http://visitmix.com/LabNotes/Intro-To-The-Archivist">http://visitmix.com/LabNotes/Intro-To-The-Archivist</a>&nbsp;and you can download the source code here: <a href="http://code.msdn.microsoft.com/archivist">http://code.msdn.microsoft.com/archivist</a>.&nbsp;</p> <p><img src="http://rhizohm.net/irhetoric/image.axd?picture=2010%2f6%2flabsFeatured01TheArchivist.png" alt="" /></p> <p>Been quite an adventure building and shipping this puppy --&nbsp;looking forward to&nbsp;seeing&nbsp;what happens now that it is&nbsp;out in the wild.</p> <p>&nbsp;</p> <p>&nbsp;</p> http://rhizohm.net/irhetoric/post/2010/06/28/The-Archivist-Is-Live!.aspx Karsten Januszewski [MS] 2176 2010-06-28T19:57:00 BeeEye (Bing Image Viewer) <p>BeeEye is a Bing Image viewer application. Its got a very Blend<em>ish </em>look and feel and was a quick project for our intern, Aykut Bal. </p> <p>Its Multitouch enabled and also has some facebook integration. The search history keep track of previous image searches along with the thumbnails. It also showcases the jumplist feature in Win7.</p> <p>you can find the app\code at <a href="HTTP://BEEEYE.CODEPLEX.COM">LINK</a>&nbsp;.. Give it a try...</p> <p><img src="http://blogs.msdn.com/resized-image.ashx/__size/750x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-51-01/2068.beeeye.jpg" border="0" /></p> <div align="center" class="shareblock"><strong>Share this post<br /></strong><a target="_blank" href="mailto:?body=Thought you might like this: http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx&amp;subject=BeeEye (Bing Image Viewer)" title="Share via Email"><img src="http://blogs.msdn.com/photos/llester/images/1445315/original.aspx" border="0" /></a> <a title="Submit to digg.com" target="_blank" href="http://www.digg.com/submit?url=http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx&amp;phase=2&amp;title=BeeEye (Bing Image Viewer)"><img src="http://blogs.msdn.com/photos/llester/images/1445312/original.aspx" border="0" /></a> <a target="_blank" href="http://www.facebook.com/sharer.php?u=http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx&amp;t=BeeEye (Bing Image Viewer)" title="Facebook"><img src="http://blogs.msdn.com/photos/llester/images/9973564/original.aspx" border="0" /></a> <a title="Submit to del.icio.us" target="_blank" href="http://del.icio.us/post?url=http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx&amp;title=BeeEye (Bing Image Viewer)"><img src="http://blogs.msdn.com/photos/llester/images/1445311/original.aspx" border="0" /></a> <a target="_blank" href="http://www.twitter.com/home?status=Currently+Reading:+http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx" title="Share link on Twitter"><img src="http://blogs.msdn.com/photos/llester/images/9973581/original.aspx" border="0" /></a> <a target="_blank" href="http://dotnetshoutout.com/Submit?url=http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx" title="Submit to .NetShoutOut"><img src="http://blogs.msdn.com/photos/llester/images/9973600/original.aspx" border="0" /></a> <a title="Submit to dotnetkicks.com" target="_blank" href="http://www.dotnetkicks.com/submit/?url=http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx&amp;title=BeeEye (Bing Image Viewer)"><img src="http://blogs.msdn.com/photos/llester/images/1445375/original.aspx" border="0" /></a> <a title="Stumble It" target="_blank" href="http://www.stumbleupon.com/submit?url=http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx&amp;title=BeeEye (Bing Image Viewer)"><img src="http://blogs.msdn.com/photos/llester/images/9191709/original.aspx" border="0" /></a> </div> <p>&nbsp;</p><div style="clear:both;"></div><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10030438" width="1" height="1"> http://blogs.msdn.com/b/llobo/archive/2010/06/28/beeeye-bing-image-viewer.aspx Lester Lobo 2175 2010-06-28T12:56:00 2D matrices in WPF and Silverlight <p>I&#39;ve just published <a href="http://www.odewit.net/ArticleContent.aspx?id=WpfSl2DMatrix&amp;format=html&amp;lang=en" target="_blank">a review&nbsp;article about 2D matrices</a>, which specifically addresses the rotation calculations. To be clear on the fundamentals...</p> <p><img src="http://www.odewit.net//Articles/WpfSl2DMatrix/Rotation2D.png" alt="" /></p> <p>&nbsp;</p><img src="http://blogs.windowsclient.net/aggbug.aspx?PostID=326141" width="1" height="1"> http://blogs.windowsclient.net/odewit/archive/2010/06/27/Matrix2D.aspx Olivier Dewit 2174 2010-06-27T18:45:00 Appearing on .NET Rocks <p> I will be appearing on a special Live Weekend edition of the Internet radio show .NET Rocks with hosts Carl Franklin and Richard Campbell. Many guests are scheduled; I'm slated for 9:00 &#x2013; 10:00 AM Eastern Time on Sunday, June 27, 2010. Because it's live, you can call in and chat! Details are here: </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/06/Appearing-on-Dot-NET-Rocks.html Charles Petzold 2172 2010-06-26T15:21:44 The Mathematics of Pathological Tennis <p> Many tennis fans seemed to enjoy the 5th set of the recent Wimbledon match between John Isner and Nicolas Mahut. In the absence of a tie-break for the final set, it went on for 138 games, finally ending at an unfathomable score of 70-68 with only one break of serve at the end. </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/06/The-Mathematics-of-Pathological-Tennis.html Charles Petzold 2171 2010-06-25T17:06:22 Visual Studio 2010 WPF Trace Settings Default Is Incorrect A few weeks ago I found that after setting the attached property PresentationTraceSources.TraceLevel=High on a binding, I was not getting the expected verbose output. You can see an obvious error in the Path property name.&#160; &#60;TextBlock Text=&#34;{Binding diag:PresentationTraceSources.TraceLevel=High, Path=XCustomerID}&#34; /&#62; Using the above in WPF 3.5 SP1 would result in many messages being outputted in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=karlshifflett.wordpress.com&blog=1204518&post=1480&subd=karlshifflett&ref=&feed=1" /> http://karlshifflett.wordpress.com/2010/06/24/visual-studio-2010-wpf-trace-settings-default-is-incorrect/ Karl Shifflett [MS] 2169 2010-06-24T20:18:22 Creating A Silverlight Blog That Doesn’t Suck Want to stand out from the crowd? Provide me with information I can't get elsewhere.... You have to focus on what your blog has to offer that is different, new, interesting, better than all the other blogs available, or I return to my original question: is this worth doing? http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/tfDbVtiWJFA/ Jesse Liberty [MS] 2168 2010-06-24T19:27:19 HyperVideo & Windows Phone 7 Project Update &#160; This is a quick update on the next steps for the HyperVideo Project that will touch on the following three sub-projects scheduled to be completed in the next six months: Update to the web-based project (HVP v2) Initial “port” of the HVP to Windows Phone 7&#160; (HVP/WP7 v1) Transmedia inspired WP7 application (HVP/WP7 v2) [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/uWzh-rZ8Ej8/ Jesse Liberty [MS] 2167 2010-06-23T20:12:39 HttpClient and HttpResponseMessage Unhappy in Medium Trust <p>Just hit an issue where I was using the WCF REST Starter kit and their wrapper methods for handling HttpWebRequest and HttpWebResponse for consuming ATOM. All was fine -- until I deployed. Then I was getting a securtiy exception.&nbsp; So, I ported the code to use raw HttpWebRequest and all worked. My guess is that my provider has configured something to explicitly allow for HttpWebRequest but not wrapper methods around it. Or something. Anyway, here was my old code:</p> <p style="PADDING-LEFT: 30px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private SyndicationFeed GetFeed(string url)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (HttpClient http = new HttpClient())<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (HttpResponseMessage resp = http.Get(url))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resp.EnsureStatusIsSuccessful();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return resp.Content.ReadAsSyndicationFeed();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;</p> <p>And here's my new code:</p> <p>&nbsp;&nbsp; private SyndicationFeed GetFeed(string url)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (response == null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (response.StatusCode != HttpStatusCode.OK)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return SyndicationFeed.Load(reader);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> http://rhizohm.net/irhetoric/post/2010/06/19/HttpClient-and-HttpResponseMessage-Unhappy-in-Medium-Trust.aspx Karsten Januszewski [MS] 2165 2010-06-20T03:47:00 Optical Art <p>This picture is wack:</p> <p>&nbsp;</p> <p><img src="http://rhizohm.net/irhetoric/image.axd?picture=2010%2f6%2funtitled.bmp" alt="" /></p> http://rhizohm.net/irhetoric/post/2010/06/18/Optical-Art.aspx Karsten Januszewski [MS] 2164 2010-06-18T22:51:00 TestAPI V0.5 Released <p><a href="http://testapi.codeplex.com/">TestAPI</a> -&nbsp;It is a library of <b>test and utility APIs</b> that enables developers and testers to create testing tools and automated tests for .NET and Win32 applications. TestApi provides a set of common test building blocks -- types, data-structures and algorithms -- in a simple, layered, componentized and documented stack. </p> <p>Its now the 5th version. In this release, we have put in a lot of fixes and updated things. </p> <p>- New Theme Changing API - enables testing on different OS themese</p> <p>- Sub image comparison support</p> <p>- Revamped variation generation API</p> <p>- Fixes\updates to command line parsing, tests, string generation, .....</p> <p>&nbsp;</p> <p>Please do send feedback. Features are driven based on user feedback :)</p> <div align="center" class="shareblock"><strong>Share this post<br /></strong><a target="_blank" href="mailto:?body=Thought you might like this: http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx&amp;subject=TestAPI V0.5 Released" title="Share via Email"><img src="http://blogs.msdn.com/photos/llester/images/1445315/original.aspx" border="0" /></a> <a title="Submit to digg.com" target="_blank" href="http://www.digg.com/submit?url=http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx&amp;phase=2&amp;title=TestAPI V0.5 Released"><img src="http://blogs.msdn.com/photos/llester/images/1445312/original.aspx" border="0" /></a> <a target="_blank" href="http://www.facebook.com/sharer.php?u=http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx&amp;t=TestAPI V0.5 Released" title="Facebook"><img src="http://blogs.msdn.com/photos/llester/images/9973564/original.aspx" border="0" /></a> <a title="Submit to del.icio.us" target="_blank" href="http://del.icio.us/post?url=http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx&amp;title=TestAPI V0.5 Released"><img src="http://blogs.msdn.com/photos/llester/images/1445311/original.aspx" border="0" /></a> <a target="_blank" href="http://www.twitter.com/home?status=Currently+Reading:+http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx" title="Share link on Twitter"><img src="http://blogs.msdn.com/photos/llester/images/9973581/original.aspx" border="0" /></a> <a target="_blank" href="http://dotnetshoutout.com/Submit?url=http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx" title="Submit to .NetShoutOut"><img src="http://blogs.msdn.com/photos/llester/images/9973600/original.aspx" border="0" /></a> <a title="Submit to dotnetkicks.com" target="_blank" href="http://www.dotnetkicks.com/submit/?url=http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx&amp;title=TestAPI V0.5 Released"><img src="http://blogs.msdn.com/photos/llester/images/1445375/original.aspx" border="0" /></a> <a title="Stumble It" target="_blank" href="http://www.stumbleupon.com/submit?url=http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx&amp;title=TestAPI V0.5 Released"><img src="http://blogs.msdn.com/photos/llester/images/9191709/original.aspx" border="0" /></a> </div> <p>&nbsp;</p><div style="clear:both;"></div><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10027015" width="1" height="1"> http://blogs.msdn.com/b/llobo/archive/2010/06/18/testapi-v0-5-released.aspx Lester Lobo 2163 2010-06-18T14:54:00 Some basic sample to make your code “Linq ready” <p>&nbsp;</p> <p>Linq has been shipped with VS2008/.Net 3.5 and is not really new. If more and more people are getting used to its syntax, it&rsquo;s sometimes hard to imagine all the scenarii where Linq to object can replace the classical way we program. During some Silverlight coding, I changed my code to make it run in a better Linq spirit and I wanted to share with you this little sample.</p> <p>Silverlight (and WPF) maintains a tree of visuals. A useful class named VisualTreeHelper provides a very simple api to navigate this tree. One very common scenario is to look for the first visual parent of a T type for a given control. For instance, your control is in a template and you want to retrieve the templated control which you know is a ListBoxItem.</p> <p>The VisualTreeHelper.GetParent() method (see prototype below) simply gives the graphical parent of any visual (as DependencyObject).</p> <div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:6555de84-0bbd-49b0-9fba-cf205ea4cdbf" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"> <pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> VisualTreeHelper { </span><span style="color: #008000;">//</span><span style="color: #008000;"> </span><span style="color: #008000;">//</span><span style="color: #008000;"> Summary: </span><span style="color: #008000;">//</span><span style="color: #008000;"> Returns an object's parent object in the visual tree. </span><span style="color: #008000;">//</span><span style="color: #008000;"> </span><span style="color: #008000;">//</span><span style="color: #008000;"> Parameters: </span><span style="color: #008000;">//</span><span style="color: #008000;"> reference: </span><span style="color: #008000;">//</span><span style="color: #008000;"> The object to get the parent object for. </span><span style="color: #008000;">//</span><span style="color: #008000;"> </span><span style="color: #008000;">//</span><span style="color: #008000;"> Returns: </span><span style="color: #008000;">//</span><span style="color: #008000;"> The parent object of the reference object in the visual tree. </span><span style="color: #008000;">//</span><span style="color: #008000;"> </span><span style="color: #008000;">//</span><span style="color: #008000;"> Exceptions: </span><span style="color: #008000;">//</span><span style="color: #008000;"> System.InvalidOperationException: </span><span style="color: #008000;">//</span><span style="color: #008000;"> reference is null, or is not a valid System.Windows.UIElement.</span><span style="color: #008000;"> </span><span style="color: #000000;"> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> DependencyObject GetParent(DependencyObject reference); ... } </span></pre> <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></!--></div> <p>Let&rsquo;s try to implement this simple scenario.</p> <p> <div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:fbc73cbc-ae6a-438e-9c0a-1623a5be92cc" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"> <pre style="background-color:White;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> MyDependencyObjectExtensions { </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> T GetVisualParent</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(</span><span style="color: #0000FF;">this</span><span style="color: #000000;"> DependencyObject source) <br /></span><span style="color: #0000FF;"><span style="color: #000000;"> </span>where</span><span style="color: #000000;"> T : </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> { </span><span style="color: #0000FF;">do</span><span style="color: #000000;"> { source </span><span style="color: #000000;">=</span><span style="color: #000000;"> VisualTreeHelper.GetParent(source); } </span><span style="color: #0000FF;">while</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">(source </span><span style="color: #0000FF;">is</span><span style="color: #000000;"> T) </span><span style="color: #000000;">&amp;&amp;</span><span style="color: #000000;"> (source </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">)); </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> source </span><span style="color: #0000FF;">as</span><span style="color: #000000;"> T; } }</span></pre> <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></!--></div> <br />We can now call: <br /><br /> <div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:68bd0ce7-6918-4d6c-a47d-88cd7a69c8b8" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"> <pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #000000;">var lbi </span><span style="color: #000000;">=</span><span style="color: #000000;"> button1.GetVisualParent</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">ListBoxItem</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">();</span></pre> <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></!--></div> <br />Now let&rsquo;s try to think in a Linq way. From a given control in the control tree, we can consider all its graphical parents until the root (Page or Window) to be an iteration. In this first implementation we are classically using a while loop to retrieve each parent one by one. This is exactly the definition of an IEnumerable.</p> <p>In a first step we will just try to retrieve the list of parents :</p> <p> <div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e0af6ac4-1482-4fc0-8841-f90d6ebc00be" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"> <pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> MyDependencyObjectExtensions { </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> IEnumerable</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">DependencyObject</span><span style="color: #000000;">&gt;<br /></span><span style="color: #000000;"> GetVisualParents(</span><span style="color: #0000FF;">this</span><span style="color: #000000;"> DependencyObject source) { </span><span style="color: #0000FF;">while</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">true</span><span style="color: #000000;">) { source </span><span style="color: #000000;">=</span><span style="color: #000000;"> VisualTreeHelper.GetParent(source); </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (source </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">) </span><span style="color: #0000FF;">yield</span><span style="color: #000000;"> </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> source; </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> </span><span style="color: #0000FF;">yield</span><span style="color: #000000;"> </span><span style="color: #0000FF;">break</span><span style="color: #000000;">; } } }</span></pre> <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></!--></div> <br />Now we have a IEnumerable (a Linq compatible source), we can look for the first parent of a T type using Linq ! <br />I have also created a version allowing to define the depth of your query in case you don&rsquo;t want to find the first T element but a further one.</p> <p> <div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:14f93ae1-d11e-4fe2-ade0-3237f279a54a" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"> <pre style="background-color:#FFFFFF;overflow: auto;;font-family:Microsoft Sans Serif;font-size:8,25"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> MyDependencyObjectExtensions { </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> IEnumerable</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">DependencyObject</span><span style="color: #000000;">&gt;<br /></span><span style="color: #000000;"> GetVisualParents(</span><span style="color: #0000FF;">this</span><span style="color: #000000;"> DependencyObject source) { </span><span style="color: #0000FF;">while</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">true</span><span style="color: #000000;">) { source </span><span style="color: #000000;">=</span><span style="color: #000000;"> VisualTreeHelper.GetParent(source); </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (source </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">) </span><span style="color: #0000FF;">yield</span><span style="color: #000000;"> </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> source; </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> </span><span style="color: #0000FF;">yield</span><span style="color: #000000;"> </span><span style="color: #0000FF;">break</span><span style="color: #000000;">; } } </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> T GetVisualParent</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(</span><span style="color: #0000FF;">this</span><span style="color: #000000;"> DependencyObject source)<br /> </span><span style="color: #0000FF;">where</span><span style="color: #000000;"> T : </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> { </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> source.GetVisualParent</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(</span><span style="color: #800080;">0</span><span style="color: #000000;">); } </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> T GetVisualParent</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(</span><span style="color: #0000FF;">this</span><span style="color: #000000;"> DependencyObject source, </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> level)<br /></span><span style="color: #000000;"> </span><span style="color: #0000FF;">where</span><span style="color: #000000;"> T : </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> { </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> source.GetVisualParents().OfType</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">().Skip(level).FirstOrDefault(); } } </span></pre> <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></!--></div> <br />We can see how Linq simplifies the implementation and the composition possibilities.</p> <p>Last effort, let&rsquo;s try to imagine a generic way to create enumerables from functional parts.</p> <p>In our case we have :</p> <ul> <li>the starting value</li> <li>the way we get the next value</li> <li>the exit condition</li> </ul> <p> <div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:38675201-4f67-476e-b107-c7f1d9f00993" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"> <pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> EnumerableHelper { </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> IEnumerable</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> Create</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(T startElement,<br /> Func</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T, T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> nextElementProvider, Predicate</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> exitCondition) { </span><span style="color: #0000FF;">while</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">true</span><span style="color: #000000;">) { startElement </span><span style="color: #000000;">=</span><span style="color: #000000;"> nextElementProvider(startElement); </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">exitCondition(startElement)) </span><span style="color: #0000FF;">yield</span><span style="color: #000000;"> </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> startElement; </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> </span><span style="color: #0000FF;">yield</span><span style="color: #000000;"> </span><span style="color: #0000FF;">break</span><span style="color: #000000;">; } } </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> IEnumerable</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> Create</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(T startElement,<br /> Func</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T, T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> nextElementProvider) { </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> Create(startElement, nextElementProvider, e </span><span style="color: #000000;">=&gt;</span><span style="color: #000000;"> e </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">); } } </span></pre> <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></!--></div> <br />We can now call :</p> <p> <div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f7b72861-6578-4d2b-8a6d-a9ba54eff391" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"> <pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #000000;">var parents </span><span style="color: #000000;">=</span><span style="color: #000000;"> EnumerableHelper.Create(<br /> button1 </span><span style="color: #0000FF;">as</span><span style="color: #000000;"> DependencyObject,<br /> d </span><span style="color: #000000;">=&gt;</span><span style="color: #000000;"> VisualTreeHelper.GetParent(d));<br /> var lbi </span><span style="color: #000000;">=</span><span style="color: #000000;"> parents.OfType</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">ListBoxItem</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">().FirstOrDefault(); </span></pre> <!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></!--></div> <br />You can notice how generic is the Create method. From the caller view the Enumerable is created &ldquo;on demand&rdquo;.</p><div style="clear:both;"></div><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10026913" width="1" height="1"> http://blogs.msdn.com/b/mitsu/archive/2010/06/18/some-basic-sample-to-make-your-code-linq-ready.aspx Mitsuru Furuta [MS] 2162 2010-06-18T10:58:00 Silverlight As Transmedia Platform – Silverlight TV I&#8217;m very excited to say that my discussion with John Papa about Silverlight as a Transmedia Storytelling Platform is live. View Video http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/e-7fSyAmASI/ Jesse Liberty [MS] 2161 2010-06-17T18:57:25 Silverlight As A Transmedia Platform The advent of Windows Phone 7 is particularly exciting to current Silverlight programmers, because Silverlight (along with .xna) is the development platform for the new phone.  I recently recorded two Silverlight TV episodes, and in one I created a typical form that might appear in any LOB application, but I created it simultaneously on both [...] http://feedproxy.google.com/~r/JesseLiberty-SilverlightGeek/~3/3Z7M6wkirL8/ Jesse Liberty [MS] 2160 2010-06-17T17:01:00 Orientation Strategies for Windows Phone 7 <p> I've recently been thinking about ways to deal with orientation changes in Windows Phone 7. (That's when the user turns the phone sideways from portrait mode to landscape mode or back again.) I've also been working on the way-overlong chapter on data binding in my forthcoming book <a href="http://www.charlespetzold.com/phone"><i>Programming Windows Phone 7</i></a>, and it occurred to me that I might deal with orientation using data binding and data conversion techniques. </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/06/Orientation-Strategies-for-Windows-Phone-7.html Charles Petzold 2159 2010-06-16T19:24:46 Flip-Number Clock in Silverlight <p> I've seen some print ads recently that feature a phone with a simulation of 1960's style flip-number clock. Such a clock is fairly trivial in Silverlight: </p><p>... more ...</p> http://www.charlespetzold.com/blog/2010/06/Flip-Number-Clock-in-Silverlight.html Charles Petzold 2158 2010-06-16T18:18:04