<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Joel Varty : Silverlight</title><link>http://weblogs.asp.net/joelvarty/archive/tags/Silverlight/default.aspx</link><description>Tags: Silverlight</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Silverlight Databinding – The Observable Collection</title><link>http://weblogs.asp.net/joelvarty/archive/2008/11/17/silverlight-databinding-the-observable-collection.aspx</link><pubDate>Mon, 17 Nov 2008 23:19:22 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6744536</guid><dc:creator>joelvarty</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/joelvarty/rsscomments.aspx?PostID=6744536</wfw:commentRss><comments>http://weblogs.asp.net/joelvarty/archive/2008/11/17/silverlight-databinding-the-observable-collection.aspx#comments</comments><description>&lt;p&gt;If you&amp;#8217;re coming from the ASP.Net world and you want to start building silverlight controls, databinding is one those things that works somewhat the same, yet somewhat differently from the standard DataSource, DataBind() world that you may be used to.&lt;/p&gt;  &lt;p&gt;For one thing, databinding in ASP.Net is done in a stateless way &amp;#8211; once that binding operation is completed, it&amp;#8217;s a done deal and if you want to change anything, now you have to manipulate the underlying controls that were created as a result of the data binding, or else change the underlying data objects and call DataBind() again.&lt;/p&gt;  &lt;p&gt;That&amp;#8217;s what we are used to &amp;#8211; but it&amp;#8217;s certainly not ideal. Enter Silverlight and the &lt;b&gt;ObservableCollection&amp;lt;T&amp;gt;&lt;/b&gt;. This is a generic list type that allows you to put any object into it. This list implements &lt;b&gt;INotifyCollectionChanged&lt;/b&gt;, such that it specifies and event that automatically notifys an underlying container when anything in the list has changed.&lt;/p&gt;  &lt;p&gt;So that&amp;#8217;s step 1 &amp;#8211; use the &lt;b&gt;ObservableCollection&lt;/b&gt; for you business object collection. Take note that by default, a WCF service proxy class in Silverlight will use this type of collection by default.&lt;/p&gt;  &lt;p&gt;Then, in your actual data object classes, you need to implement the &lt;b&gt;INotifyPropertyChanged &lt;/b&gt;on your data objects &amp;#8211; this will allow you to raise the &lt;b&gt;PropertyChanged &lt;/b&gt;event whenever the state of you object changes to the point where you want to notify the underlying collection or container that the state has changed.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://weblogs.asp.net/blogs/joelvarty/WindowsLiveWriter/SilverlightDatabindingTheObservableColle_10060/personclass.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="408" alt="" src="http://weblogs.asp.net/blogs/joelvarty/WindowsLiveWriter/SilverlightDatabindingTheObservableColle_10060/personclass_thumb.png" width="644" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Remember too, that this stuff isn&amp;#8217;t really &amp;#8220;Silverlight&amp;#8221; specific &amp;#8211; it was originally designed for databinding in Xaml for WPF, but since Silverlight using Xaml and a subset of WPF, this is really just following along the same paradigm.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;What does all this really mean?&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;It means that once you have set up your data collections and underlying types, you can now follow the normal databinding rules, but once you change the underlying data objects themselves, either by modifying the collection or a property of an item in the collection, then the UI object will be updated too. This will only happen when the BindingMode is done using OneWay (the default), or TwoWay. The OneTime binding mode ignores any changes to the underlying collections so you can safely change them later without worrying about your UI going all wonky (or which thread you are operating from).&lt;/p&gt;  &lt;p&gt;Threading will become very important when you are updating in item in an ObservableCollection &amp;#8211; you need to be aware of what thread you are currently running in and possible use the Dispatcher to make that change &amp;#8211; since the Notifier events will bubble up to the UI synchronously from the call you are in. Luckily we can trigger the dispatch from an anonymous delegate, so we don&amp;#8217;t need to make extraneous methods for these any more.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/joelvarty/WindowsLiveWriter/SilverlightDatabindingTheObservableColle_10060/dispatcher.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="239" alt="" src="http://weblogs.asp.net/blogs/joelvarty/WindowsLiveWriter/SilverlightDatabindingTheObservableColle_10060/dispatcher_thumb.png" width="644" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So that&amp;#8217;s the basics of the underpinnings of data binding in Silverlight (and thus, in Xaml). I like that it follows a similar front-end markup/code behind model to ASP.Net, but allows us to take advantage of a stateful environment &amp;#8211; especially for calling web service and REST APIs asynchronously.&lt;/p&gt;  &lt;p&gt;More later &amp;#8211; joel.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6744536" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/joelvarty/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Threading/default.aspx">Threading</category></item><item><title>Silverlight 2 - Finally a version that can change the world!</title><link>http://weblogs.asp.net/joelvarty/archive/2008/10/15/silverlight-2-finally-a-version-that-can-change-the-world.aspx</link><pubDate>Wed, 15 Oct 2008 13:10:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6682062</guid><dc:creator>joelvarty</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/joelvarty/rsscomments.aspx?PostID=6682062</wfw:commentRss><comments>http://weblogs.asp.net/joelvarty/archive/2008/10/15/silverlight-2-finally-a-version-that-can-change-the-world.aspx#comments</comments><description>&lt;p&gt;Yes, folks - that title is not a joke.&amp;#160; Silverlight can completely change how we think about the web.&lt;/p&gt;  &lt;p&gt;We're not writing activeX controls anymore, we're not coding &amp;quot;ActionScript&amp;quot; on a &amp;quot;Timeline&amp;quot; - we're talking about something revolutionary here.&lt;/p&gt;  &lt;p&gt;If you look at the underlying premises of Asp.Net - Markup with Code-behind, and how well it has been received by the developer community, then the same paradigm in the WFP world has been waiting for Silverlight 2 to explode onto the scene.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Why will it succeed?&amp;#160; We've had 1.0 for awhile now, and it hasn't &amp;quot;changed the world.&amp;quot;&amp;#160; What gives?&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;This version brings &amp;quot;everything else&amp;quot; that 1.0 forgot.&amp;#160; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We have actual layout managers &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;like StackPanel and Grid - we won't talk about how the Grid layout manager is compared to table, but is really quite a different of a table than HTML.&lt;/li&gt;      &lt;li&gt;and a ton of Controls to work with and extend.&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;We have real language support - &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;C#, boys and girls.&amp;#160; Go play.&lt;/li&gt;      &lt;li&gt;And some other languages too.&amp;#160; Whatever.&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;Cross Domain Network requests use the same policy file as Flash&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Here's where being just like Flash actually matters - since so many people have this policy file in place to allow for cross-domain requests, using it in Silverlight really makes sense.&lt;/li&gt;      &lt;li&gt;These networks requests can be truly asynchronous.&amp;#160; Not &amp;quot;fake&amp;quot; asynchronous like JavaScript.&amp;#160; &lt;/li&gt;      &lt;li&gt;This doesn't compete with AJAX - it is just way better.&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;LINQ support.&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;This is becoming a staple of .Net development.&amp;#160; I have stopped bothering to follow ActionScript, but I am fairly sure it can't do LINQ.&amp;#160; If you are a Flash developer, and you want to do &amp;quot;real&amp;quot; developer, look long and hard at Silverlight 2.&lt;/li&gt;      &lt;li&gt;This is demonstrated by Scott Guthrie in his blog tutorial on Silverlight 2.&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;We have actual TOOL SUPPORT (I'm getting more excited as I write this - calm down, man.&amp;#160; Calm down.)&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;The Visual Studio 2008 add-in works like a charm.&amp;#160; No problems reported from me except for a few Intellisense quirks.&amp;#160; This is a far cry from the crashy crappiness that saw me flounder around with the 1.0 tools for about an hour before I decided to wait for 2.0 to get serious about Silverlight development.&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;The designer tools allow designers to be designers and developers to be.... developers&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;The code-behind model is supplemented with the style-templating mechansim that is not too dissimilar to Asp.Net skins, except it allow more declarative control over how and when certain properties (whether they be style related or Content related) can be set.&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Download the add-on for Visual Studio 2008 &lt;a href="http://msdn.microsoft.com/en-us/silverlight/default.aspx" target="_blank"&gt;here&lt;/a&gt; - you need SP1 for this, so get that first.&lt;/p&gt;  &lt;p&gt;Scott's tutorial post series is &lt;a href="http://weblogs.asp.net/scottgu/pages/silverlight-2-end-to-end-tutorial-building-a-digg-search-client.aspx" target="_blank"&gt;here&lt;/a&gt;.&amp;#160; Read this first.&amp;#160; Then read it again and think about what it all MEANS.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;My final thoughts:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;This is the big chance for WPF development to finally supplant Windows Forms and take us out of the Visual Basic style of UI forever.&amp;#160; &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;This means that all of the crappy-looking corporate apps that people argue bring so much legacy value to desktop, can finally be re-written in a way that doesn't stink, and in a way that doesn't exclude non-Windows machines.&amp;#160; &lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;We can &amp;quot;sort of&amp;quot; share code between Silverlight and WPF Applications.&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Make this easier, Microsoft.&amp;#160; &lt;/li&gt;      &lt;li&gt;Go back in time and do this yesterday, then tell me how I missed this in the documentation.&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;Don't follow the examples when you see declarative event binding&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;This is my worst pet peave of Asp.Net and I have started seeing it in virtually every XAML demo app out there.&lt;/li&gt;      &lt;li&gt;Declare your events in the code-behind, not the XAML markup, folks.&amp;#160; Think about how hard it will be maintain code that has a ton of this event bindings - you'll insane with the ctrl-F to locate where your events are referencing, and then you'll wish you'd listened to me.&lt;/li&gt;      &lt;li&gt;I'm guessing the exception to this is where a control that you want to bind an event to is inside a data-bound template.&amp;#160; Then you're allowed to bind the event in the markup.&amp;#160; I guess.&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When will it take over the world?&amp;#160; &lt;/p&gt;  &lt;p&gt;In my opinion, as soon as everyone else realizes that the absolute BEST video streaming technology just got paired with the absolute BEST programming support is available in an a cross platform browser extension, this thing will take off big time.&amp;#160; &lt;/p&gt;  &lt;p&gt;I'll be putting it into my apps as soon as I can.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Rock on - joel.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6682062" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/joelvarty/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Flash/default.aspx">Flash</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Threading/default.aspx">Threading</category></item><item><title>The Ubiquitous, Mobile Web: The Final Frontier</title><link>http://weblogs.asp.net/joelvarty/archive/2008/07/16/the-ubiquitous-mobile-web-the-final-frontier.aspx</link><pubDate>Wed, 16 Jul 2008 21:10:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6408107</guid><dc:creator>joelvarty</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/joelvarty/rsscomments.aspx?PostID=6408107</wfw:commentRss><comments>http://weblogs.asp.net/joelvarty/archive/2008/07/16/the-ubiquitous-mobile-web-the-final-frontier.aspx#comments</comments><description>&lt;p&gt;The web works better when web sites are tailored to the capabilities of the platform.&lt;/p&gt;  &lt;p&gt;That's a given, as far as I am concerned.&amp;#160; &lt;/p&gt;  &lt;p&gt;I have avoiding dealing with this issue in the past in terms of mobile devices in the hopes that the browsers mobile phones will eventually mature to point of approaching desktop capabilities.&amp;#160; Also, I am sure that there is some amount of push back to browser quirkiness following the Netscape/IE browser quirk wars of the past decades.&lt;/p&gt;  &lt;p&gt;But now, as I await delivery of an iPhone 3G, I wonder if I might be doing more to push development for the mobile platform in general.&lt;/p&gt;  &lt;p&gt;For example, I have used the Opera 9.5 browser (a leaked beta :) on my HTC TyTN for the past few months and I am amazed by how fluidly and quickly it renders and zooms fairly complex web pages - even on a QVGA (320x240) screen.&amp;#160; I am hoping/assuming that mobile Safari, which Opera is ostensibly attempting to surpass with it's mobile browser efforts, will be even more useful and amazing.&lt;/p&gt;  &lt;p&gt;It does beg the question, though, about where the responsibility for the overall mobile browsing experience lies: the browser implementation, or the web developers themselves.&amp;#160; As an architect, it makes perfect sense that we should design and build web controls that will degrade their functionality based on the mobile browser's known capabilities.&amp;#160; This rarely happens.&lt;/p&gt;  &lt;p&gt;Most web sites, in my experience, are envisioned by people who haven't had exposure to the Internet on the kinds of mobile browsers, like Safari and Opera, that actually make mobile browser worthwhile.&amp;#160; That being said, it should also be noted that most web site are also envisioned as a set of features that must answer to features on competing web sites.&amp;#160; Far from being able to think about what the user experience ought to be on a handheld platform, we often can't even escape the vertical market that we operate within.&lt;/p&gt;  &lt;p&gt;So what is the answer?&amp;#160; &lt;/p&gt;  &lt;p&gt;Should a mobile web site come &amp;quot;out of the box&amp;quot; when a developer drops a custom web control on a page?&amp;#160; &lt;/p&gt;  &lt;p&gt;Should we be pushing for a second stream of mobile development to complement the &amp;quot;standard&amp;quot; mobile development?&lt;/p&gt;  &lt;p&gt;Or should we just let the mobile device handle the page that was designed for the desktop?&lt;/p&gt;  &lt;p&gt;Should Flash and Silverlight be expected to run in these environments?&lt;/p&gt;  &lt;p&gt;At this point, do we even know what a &amp;quot;mobile device&amp;quot; mean?&amp;#160; Does it include UMPCs, MIDs (Mobile Internet Devices), or the smaller laptops like the Asus EEE PC (and all of its copy cats)?&lt;/p&gt;  &lt;p&gt;So many questions, and no answers.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6408107" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Safari/default.aspx">Safari</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Flash/default.aspx">Flash</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Mobile/default.aspx">Mobile</category></item><item><title>What is silverlight good for (yet)?</title><link>http://weblogs.asp.net/joelvarty/archive/2008/01/23/what-is-silverlight-good-for-yet.aspx</link><pubDate>Wed, 23 Jan 2008 19:09:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5640643</guid><dc:creator>joelvarty</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/joelvarty/rsscomments.aspx?PostID=5640643</wfw:commentRss><comments>http://weblogs.asp.net/joelvarty/archive/2008/01/23/what-is-silverlight-good-for-yet.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;I have just passed up my first chance to build a silverlight component into a website.&amp;nbsp; It was a tough choice, since everyone involved generally agreed that Silverlight was a great technology and would add a ton of bling to the site.&lt;/P&gt;
&lt;P mce_keep="true"&gt;That being said, it has to be noted that Silverlight does not have a good layout system in place, as it only uses the Canvas layout from WPF&amp;nbsp;- no flow layouts, here folks! This means that you have to position every single element absolutely. And you have to code it in javascript.&amp;nbsp; And there is not built-in project template for it in VS 2008 yet, so you have to jump through some hoops to get intellisense working for you.&lt;/P&gt;
&lt;P mce_keep="true"&gt;That's not a good way to introduce yourself to a technology, in my opinion.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Here where I think Silverlight is actually a good technology to use:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Streaming video.&amp;nbsp; &lt;/DIV&gt;&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;This is one of the main commercial uses of this&amp;nbsp;technology at the moment, and it sure beats the pants of other streaming formats.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;It would greatly benefit by better tools for encoding, but Expression 2.0 looks pretty decent so far (in beta).&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Displaying vector graphics with small amounts of interactivity&lt;/DIV&gt;&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Lets face it, you can code any amount of logic yourself into a Canvas framework, but the power of Silverlight is in its ability to&amp;nbsp;reproduce WPF, which in turn is really only useful with its vector graphics capabilities, combined with the layour frameworks.&amp;nbsp; &lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Until we get more of WPF to work with, getting more experience with XAML's in terms of more static vector objects is a good idea.&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;I can't wait for Silverlight 2.0, and I can't wait until we can all save each other oodles of time be coding Asp.Net controls that aggregate a whole wack of functionality into a simple&amp;nbsp;tag&amp;nbsp;that we drop into our sites and customize to our hearts content.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;Stay tuned...&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5640643" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/joelvarty/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/joelvarty/archive/tags/Silverlight/default.aspx">Silverlight</category></item></channel></rss>