in

ExpressionBlog.com

Microsoft Expression Studio Community

This Blog

Syndication

Mirrored Blogs

Browse by Tags

All Tags » Learning Silverlight (RSS)
  • Canonical Q&A

    Every day I get about 10-30 questions that I answer with a stock response (sorry) that says something like Hello and thank you for writing. I would encourage you to post your question in the Silverlight Forums . Be sure to include: * which version of Silverlight you are running, * which version of Visual Studio and/or Blend you are using and * whatever else you can add to help reproduce the problem. Meanwhile I’ll try to look into this as well. Thank you, I hate this answer; but it is the right thing; I can’t possibly do my job and also dive deep into all the questions I get; the forum s really are the right place and 1,000 brains are better than one. Oh, and  I do follow and I do look into many (though not all) of them. That said, some questions come up a lot, and today I received a note with 4 that I must get at least five times a week, so here are my quick responses (I’ve paraphrased some of the questions) I'd like to make my website a bit more "rich" and a better UI experience for the users and I'm considering Silverlight. It currently uses….  What would be your advice? Since you are new to Silverlight you probably want to work your way through a suggested learning path and then ask a lot of questions in the forums. I wish I could spend a day (or a week) working on the design with you For this website, with respect to your multiple page example...Let's say I have 30 existing .aspx pages. Would I make page1.xaml, page2.xaml, page3.xaml, etc. that would correspond to each respective page that I currently have? Not necessarily (and I hope you’d use better names <grin>). In fact, there is no reason you wouldn’t have a mixed model, using ASP.NET where it is working for you and Silverlight for enhanced (richer, faster, etc.) experiences. Are there any resources that tell you how to convert a complex ASP.NET web site into a complex Silverlight site? Not that I know of, but more information is coming every day. Be sure to keep an eye on silverlight.net and subscribe to Silverlight Cream , and Silverlight News . 4. This may sound odd, but how do I know that wanting to do this in Silverlight is not completely strange when it works and looks satisfactory now? Still make the change and why I guess is what I'm asking here. If it is satisfactory now, go do something else <smile>. But maybe it isn’t completely satisfactory; maybe a faster richer experience, in at least some parts of the application would be valuable. Take...
  • The 5 Levels of Technophilia and Silverlight

    I used to work for a man named Larry Weiss at Citibank, who did a number of magical things (including creating the best ATMs in the world in the 1980s that still surpass anything I’ve seen other banks do yet!).  One concept that he talked about a lot (I have no idea if it was original) was the 5 levels of Technophilia, which he described as a pyramid but probably is better described as a bell curve and in fact a quick Live-Search turns up many such images. Doesn’t matter; it was his labels, and more important his one sentence examples (which I’ve paraphrased and updated) that I cared about: I – First Buyers  Technology for its own sake. Gotta’ have it. They’re the ones on line right now buying the new iPhone II Technology Lovers “Show me any any good reason, and I’ll buy it.” These folks already have FIOS and HDTV and don’t understand why anyone thinks that is odd. III Technology Comfortable “If there is a good reason, I’ll buy it, but show me the reason. After all, there is some cost to learning, some hassle to maintaining, but if you overcome my hesitation then I’m happy to buy.”  These folks are buying DVRs now and considering a GPS for their car. IV. Technology Resistant “I don’t like it, I don’t want it, but if you can really convince me that I have to have it,  I’ll complain a lot, but I’ll buy it.”  This is my mom.  Has a VCR, won’t take a DVD player as a present.  V. Go Ahead, Pull The Trigger, I’m Not Using It. Forget it, they don’t even have answering machines. So? I’ve found these quintiles to be totally   arbitrary and inconsistent, and yet a guiding principle for the past 20+ years. The fact is, I’m a Quintile I, my wife is a Quintile III and most folks fit pretty easily into one of these descriptions. Here’s how I know I’m a Quintile I.  I leave my GPS on all the time, even when I know just where I’m going. Why? Because I am totally gassed by what it is. The fact that this tiny little box is sitting in my car is just too fantastic. Think for a moment about how it works (which I only know to a first approximation: Satellites in the Global Navigation Satellite System continually transmits messages to the tiny box in my car. Each of these messages encodes the time the message was sent, as well as the satellite’s precise orbit and the almanac of the orbits of all the other satellites. Given signals from four satellites, that tiny box not only computes its position in 3 dimensional space, but also the...
  • One Man’s Guide To Silverlight Nirvana

    Every day (honest) I am asked for a path through the learning material, even though the Getting Started page offers an explicit path. And that is not surprising. We all have our own way of learning. Here is the path that I personally tend to suggest to most Silverlight neophytes. Path of quick learning: Go to Getting started and get all the links shown here Then watch the video on the same page on getting started. Once Set UP, Writing Programs Read this tutorial on interface controls. Watch [forthcoming] this video on why I made the switch to coding with Silverlight and Blend and how powerfully they work together, and then watch watch these “How Do I” videos on Blend for Programmers: Part 1 Part2 Part3 and/or read this tutorial Data Next, it’s time to focus on this video on data and then this tutorial on creating n-tier applications and data binding. Follow that with a great video on Cross Domain issues and then read up on user controls which you can supplement with this video on keyboard input followed by this video on user controls. Styles and Templates You may then want to read my tutorial and watch my videos on Styles and Templates (to be posted in the next week or two) or check out Karen Corby’s excellent 4 part series on the subject. Freestyle After all that you can pretty much move freely among the other tutorials and videos . Best of luck
  • Green Eggs and Ham Webcast Presentation

    I presented the first of a new series of live web casts today in which a number of resources were mentioned. As promised, here are links to all of them Silverlight.net Getting Started Page Learn Page Silverlight Microblog Scott Guthries’s blog entry on Expression Blend for Programmers Three videos on Blend For Programmers. One , Two , Three . Tutorial on Blend for Programmers Tutorial on Skinning and Styling Controls in Blend (to be posted soon) Register for next presentation on data binding with Blend The Traffic Light Video (silent!) Source Code For Traffic Light
  • New Live Presentation Series – Starts 6/25

    I am pleased to announce a new series, blending Conference-quality presentations delivered through Live Meeting via the Live From Redmond Series. Audience, Goal and Purpose Each presentation will provide a thorough overview of a Silverlight 2 topic with a focused  priority of explaining What is this feature and why do you care? What are the most important things you need to know? Where can you learn more? Every presentation will be paired with a blog entry containing links to videos, tutorials, and other resources to complement the material presented. The tutorials and videos will focus on how , but the Presentation will focus on What and Why. While there will be quite a bit of code shown, these are not “How Do I” presentations but rather “What do I need to know and why do I care?” presentations. Each presentations will be provided through Microsoft Webcasts in the “ Live From Redmond ” series and will be recorded for download after processing. Schedule & Registration June 25:   Controls and Events (Subtitle: Programming Silverlight 2 with Expression Blend and Visual Studio 2008). Complete description and registration .  Event ID: 1032381748 July 09: Data-binding, business objects and data sources in Silverlight. Complete description and registration .  Event ID: 1032381750 July 16 – Saruabh Pant Presents: Building Rich Internet Applications Using Microsoft Silverlight 2 July 23: Data Templates in Silverlight. Complete description and registration .  Event ID: 1032381752 August 6 Memory efficient multi-page applications in Silverlight . Complete description and registration .  Event ID: 1032381754 The dates for the next three will be settled very soon. Graphics and Transforms in Silverlight  Visual State Manager, Transitions and Animation in Silverlight Exploring Deep Zoom in Silverlight 2   Fees (none)  and Requirements (Live Meeting) Each presentation is free but you will need to register in advance.  You will also need Microsoft Live Meeting Software to view the presentation (learn more here ).
  • Who Ate My Mouse Down Event??

    Before I leave, I want to squeeze in one quick note about a problem a lot of folks are running into as they upgrade from Beta 1 to Beta 2. I’ll come back to this in more detail when I get back, but here it is in a nutshell. A breaking change in the Beta 2 upgrade is that all the controls now handle MouseLeftButtonDown/Up/Move, while graphic objects do not. That means that no built in control will pass those events on (bubble them up) anymore. So, if you revisit my example for drag and drop what you’ll find is that if you create a button that has a graphic object inside it, and you drag on the button, it will not move, but if you drag on the graphic object it will! You can see this in (the newly updated) Tutorial #1 (where the image for Drag and Drop is misleading). Dragging on the Very Little Green Man works, dragging on the button he is in, does not. That is because the Very Little Green Man consists of nothing but Graphics (elipses and paths) but the button is a control and the control eats the event. This is why figure 1.9 in the tutorial has to be replaced; you can’t drag the button, you have to drag the green man, Broken image It’s subtle but important, where the mouse is shown, you could not be dragging . Yes, in Beta 1, no in Beta 2. Fixed image Here the mouse is dragging the little green man, and that will work just fine. The full reason for this is to come, but the short explanation is that this helps controls in Silverlight behave more like controls in WPF.
  • Boston .NET Users Group Meeting

    Last night I had the opportunity to talk to a packed room at the Boston .NET User’s Group; an incredibly welcoming and most friendly group of some 150,000 screaming fans of all things Microsoft. I promised at the time to provide a few links; including of course the single most important; the link to Silverligh.net , as well as a link to my blog , to  our Getting Started page , a link to the videos and a link to the tutorials . Other important resources mentioned were Scott Guthrie’s blog ,  Tim Heuer’s Blog and  Silverlight Cream . You can subscribe to the Silverlight Microblog here , though it will be fairly quiet for the next week or so. Thanks again for coming, for your questions, for the car and for your kind words.   -j
  • What is coming soon?

    You have noticed, I’m sure, that there has been a flurry of blogging, videos and more since the release of Beta 2. That is all goodness, though it can be hard to know where to start; and the road map will differ depending on where you are in your experience with Silverlight. This is a rapidly changing environment and I’m hesitant to make promises, because things can change, but after some thought I’ve decided that it would be helpful to give you an idea of what to expect with my tutorials, videos and webcasts.  So, here is my tentative schedule through the next couple months. WebCasts Styles and Templates   Wednesday June 18 9am UTC –8 (Pacific) Deep Zoom Wednesday, July 16, 2008 9:00 Tutorials All of the tutorials are updated to Beta 2 in their  pdf form and the HTML will be updated very soon. All of the source code is already updated.  The next couple tutorials will include Styles, Templates, the Visual State Manager Graphics, Transforms, and Animation Animation In Detail The DataGrid in Detail Book Tim and I are working hard to write and publish Programming Silverlight 2 .  Our hope is to be able to provide an early look very soon. Here is one paragraph from my non-introduction (unedited and unauthorized) We’ve set out to tell you the story of Silverlight and to teach you everything you need to know to program effectively with what we believe is an amazing new technology. We have not tried to replicate the documentation nor to provide a comprehensive definition of every property, event and method of the framework. But telling the story of Silverlight is more than just picking which parts are most important; it is threading our way through a very large and complex framework in a coherent and logical way, making sense of it, and providing a guided tour through the underbrush pointing out the dangerous spots, showing the shortcuts, and warning of the dead-ends . How Do I   Videos In addition to the many videos already posted it is my plan to create videos on the following topics in the coming weeks. Styles  Templates and Visual State Manager The Visual State Manager In Depth Basic Animation in Beta 2 (with Blend) Inter-state animation In-state Animation Graphics and transforms Animating objects Data and Animation DataGrid Advanced DataGrid Popup Control Calendar Control TextBox In Depth Scroll Bars If your favorite topic is missing, just drop me a note .  Please note that some of these topics are covered already, but...
  • Beta 2 Tutorials Available Now in PDF

    I’m pleased to announce that the following tutorials are now updated for Beta 2 and available for immediate download (but only the PDF versions and the code have been updated so far, the HTML versions are not yet updated) 1 Creating Applications With Controls and Events 2 Binding Data In Silverlight 3 Filling a DataGrid using Sql, Linq and WCF 4 Instant Code Reuse: User Controls in Silverlight 5 Introducing Expression Blend For Silverlight Developers To be perfectly clear: The downloadable code is updated for Beta 2 The PDF is updated for Beta 2 The HTML is not updated to Beta 2 We’ll have the HTML updated as soon as possible. There will be a lot of information coming very fast in the next few hours and days. I recommend beginning your explorations with ScottGu’s blog post and then working your way through our new videos, tutorials, and the many other blog posts that will be appearing in the next couple days. Exciting times.
  • Popup Control

    Beta 2 includes a wealth of new controls including the Popup (that is new, right? It’s not that I just didn’t notice it before?). I received an email today asking if I’d do a short How Do I video on creating a Popup and I certainly will, but here is a wicked fast tutorial for those of you who can’t wait…. There are three approaches. 1. Create the Popup as Xaml, most easily in Blend 2. Create the Popup dynamically, most easily in Visual Studio 3. Create the Popup as a User Control (the right answer, once you’re comfortable with how Popups are created Creating the Popup in Xaml Here is a picture of what we’re going to build. The basic Silverlight control will have a button and an image….. The button’s event handler makes the Popup visible. If you are old enough to get the reference, from having watched it when it was first on, remind me to buy you a glass of milk the next time we’re at a conference together There are two important things to notice: the Popup covers any elements that are at its location (when you create it you give it a vertical and horizontal offset from the upper left of the control) and the Popup is entirely within the Silverlight control. Method 1 - Xaml Create your basic project with the Click Me button and the Image in Blend. Set their properties as usual. Then select a Popup from the Asset Library and place that inside your Grid as well. Make the Popup the container by double clicking on it, and you are ready to add the border and StackPanel. Double click on the panel to make it the container and add the TextBlock and Button. Set all the properties. Once you have the controls set, it is time to save all the files and edit in Visual Studio. Your Xaml file will look more or less like this: <UserControl xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml" x:Class= "PopUpControl.Page" xmlns:d= "http://schemas.microsoft.com/expression/blend/2008" xmlns:mc= "http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable= "d" Width= "640" Height= "480" > <Grid x:Name= "LayoutRoot" Background= "White" > <Grid.RowDefinitions> <RowDefinition Height= "0.15*" /> <RowDefinition Height= "0.85*" /> </Grid.RowDefinitions> <Button x:Name= "ShowPopupButton" Height= "40" HorizontalAlignment= "Left"...
  • Beta 2 Month

    Beta 2 has been announced, and as you know from Tim’s post and Karen Corby’s , one of the big and wonderful additions to Beta 2 is a new model for skinning Silverlight controls. This is so exciting, and so important, that my plan is to make it a central (but not quite exclusive) focus for the month of June. The timing is good, because I just finished updating all the tutorials for Beta 2 (watch for them to be posted shortly after Beta 2 is available) and the one I did not update is #3 Styles and Templates. I chose not to update that one because the new model is so much better there was no point in fixing up a tutorial on typewriters when computers are about to land on your desk. The Plan During this month I’ll be releasing A new tutorial that covers Styles, Templates and the VSM in great detail How Do I videos on Styles, Templates, Visual State Manager, and tying it all together Multiple “digging deeper” blog posts and… June 18 - Round Buttons with Visual State Manager The first in my new series of Web casts unlike any I’ve tried before: much higher value, much more information, much more use of the medium. This should just be a blast. So, sign up for the June 18 WebCast and don’t forget to join SLMicroBlog to be kept up to date.
  • Beta 2 Event Bubbling

    There are many great changes in Beta 2, and some are designed to make Silverlight more like WPF. One side effect of this is that event bubbling has changed just a bit and that bit breaks some of the examples I love to use. In Beta 1, the distinction was that all the controls handled their own click events but the more primitive events such as many of the mouse events were allowed to bubble. This allowed for interesting if not terribly useful demonstrations in which I placed a check box inside a button and was able to demonstrate that if I were to use the click event on the check box the button would never see the click, but if I used a MouseLeftButtonDown, hey! Presto! the button did see the event. This has now changed in Beta 2 to make Silverlight behave more like WPF. By and large (other than breaking my demo) this is a good thing.  The consistency now is that objects that directly derive from UI element do support event bubbling for the mouse events (that is,  Ellipse, Glyphs, Image, InkPresenter, Line, MediaElement, Path, Polygon, Polyline, Rectangle and TextBlock.)  In addition, the container classes do. Thus, if you set up the following bizarre application in which you have a grid, with a grid in it, that contains a stack panel that in turn contains a rectangle, a TextBlock, a check box, a button and a listbox (the last to show the results)… <UserControl x:Class= "EventBubbling.Page" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml" Width= "400" Height= "800" > <Grid x:Name= "LayoutRoot" Background= "White" > <Grid x:Name= "InterimGrid" > <StackPanel x:Name= "myStackPanel" Orientation= "Vertical" > <Rectangle x:Name= "myRect" Width= "30" Height= "30" Fill= "Blue" Stroke= "Red" StrokeThickness= "2" Margin= "0,10,0,10" /> <TextBlock x:Name= "myTextBlock" Text= "Hello" HorizontalAlignment= "Center" FontSize= "14" Margin= "0,10,0,10" /> <CheckBox x:Name= "myCheckBox" Content= "Check Me" Width= "80" Height= "40" Margin= "0,10,0,10" HorizontalAlignment= "Center" /> <Button x:Name= "myButton" Content= "TinyButton" Height= "30"...
  • Creating a Project from xaml and xaml.cs files

    I posted the code for the PageSwitcher app described in a previous blog post , but to save space and to make the download faster, I didn't include anything but the code (no solution or project files). A reader wrote asking how to create a project and it is a more than fair question as the answer is not obvious until you've done it a couple times, so let's walk through that example. When you download the code, you'll receive a zip file named  PageSwitcher .zip. Unzip that and you'll have a folder named PageSwitcher,   Open a new Visual Studio project and to make this example as clear as possible, let's name it something else (myPageSwitcher) and locate it in a different directory. Open Page.xaml in your new project and note the name of the project (MyPageSwitcher) <UserControl x:Class= "MyPageSwitcher.Page" Open Page.xaml.cs and note the namespace namespace MyPageSwitcher This is the information you need to hold on to for the rest of this exercise. Ready To Go There are many ways to do this, but the easiest is to delete Page.xaml, Page.xaml.cs and App.xaml and App.xaml.cs from your new project. (Don't panic!) Next, right-click on the project and choose Add->Existing items and navigate to the downloaded files and add them all. They are now in your new project. Click on all 4 xaml files and change the name of the project in the x:Class tag. Click on all 4 .cs files and change the name of the namespace (ignore the smart tag) If you want to get rid of the smart tag, use Build->Clean. Build->Rebuild Solution. You're all set Here is your new PageSwitcher.xaml <UserControl x:Class= "MyPageSwitcher.PageSwitcher" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml" Width= "400" Height= "300" > </UserControl>   And here is your new PageSwitcher.xaml.cs using System.Windows.Controls; namespace MyPageSwitcher { public partial class PageSwitcher : UserControl { public PageSwitcher() { InitializeComponent(); if ( this .Content == null ) { this .Content = new Page(); } } public void Navigate(UserControl nextPage) { this .Content = nextPage; } } }   Don't forget, once your code compiles, you can right click on the using statements and choose Organize Usings -> Remove Unused Using  which greatly cleans up your code.
  • Multi-Page Applications in Silverlight

    I wanted to build a multi-page (Search - Results) application when I realized that isn't really our model. Fortunately, I wrote to Ashish Shetty , who combines enormous knowledge with enormous kindness, and even though he is in the middle of blogging about this, he agreed that I could blog about it as well. Since I will be creating an HDI Video on this as one of my first Beta 2 videos (RSN) and since I think his solution is wicked cool, here is how you do it 1. Create a new Silverlight 2 project in Visual Studio , (I named mine, MultiPage). 2. You want to have at least three pages. Let's use the default Page.xaml as the first. Add any content you like but but include a button with a name and set the content to something like "Switch" 3. Right click on the project and click Add New Item, and add a second User Control. Name the new user control anything you want and give it any content you want. I'll call mine Page2.xaml and give it content to make it distinct: <UserControl x:Class= "MultiPage.Page2" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml" Width= "400" Height= "300" > <Grid x:Name= "LayoutRoot" Background= "Beige" > <StackPanel Orientation= "Horizontal" > <TextBlock Text= "This is Page2" FontFamily= "Comic Sans MS" FontSize= "48" VerticalAlignment= "Center" /> <Button x:Name= "SwitcherooButton" Content= "Switcheroo" Height= "40" Width= "80" Background= "Red" FontSize= "14" Margin= "20,0,0,0" /> </StackPanel> </Grid> </UserControl> Note that again I have a button for switching pages. Here is where the magic happens 4. Add a third page (I named mine PageSwitch.xaml.) Put nothing in the xaml file, because the content will be the page you want to display , but in the code-behind file add this method: public void Navigate(UserControl nextPage) { this .Content = nextPage; } 5. Wire up the buttons on all of your pages to invoke the Navigate method, passing in the page you want to navigate to. So, in Page.xaml.cs you'll add this code, public Page() { InitializeComponent(); SwitchButton.Click += new RoutedEventHandler(SwitchButton_Click); } void SwitchButton_Click( object sender, RoutedEventArgs e) { PageSwitcher ps = this .Parent...
  • Xaml vs XAML

    I received an email from Ian Griffiths who informed me that the "Xaml spec refers to Xaml as Xaml , and not XAML ." because Rob Relyea didn't like the "shouty caps" look of all upper case. After some back and forth, I contacted Rob, who wrote back that Ian is right (no surprise there) but that Rob is "...starting to use XAML" as that ship has sailed. I don't know, Rob is pretty amazing, (the image below is a link to his blog), and I'm inclined to agree with him that Xaml is a lot classier looking than XAML. I suggested that I would put the following note in Programming Silverlight A quick note on the capitalization of Xaml. Ian Griffiths (who truly knows everything) sent an email that Rob Relyea submitted the official specification with the capitalization as Xaml rather than XAML . While even Rob agrees that all upper case is the popular usage, his blog, Xamlified ( http://tinyurl.com/6h6rr5 ) is an oasis of camel case, and high quality information. This book will use both capitalizations for the sake of inconsistency. Maybe we can start a movement. I'm going to try. If nothing else, this discussion has led me to find YAAM (Yet Another Amazing Microsoftie) which makes it worthwhile. Keep an eye on his blog ; there are gems there. For those of you about to write that this is a trivial and meaningless distinction not worth the time to blog about... I pretty much agree.
More Posts Next page »