in

ExpressionBlog.com

Microsoft Expression Studio Community

This Blog

Syndication

Mirrored Blogs

Browse by Tags

All Tags » Tip of the Day (RSS)
  • Tip of the Day Microblog Launches Today

    As of today, I will attempt to add a brief Tip of the Day to the Silverlight Microblog every day. If you would like to contribute (and I hope you will) please send your tips following the directions listed here . Thanks!   -jesse
  • Tip of the Day Meets the Micro-blog

    A reader gave me what I hope will turn out to be a great idea... he wrote to lament the loss of the Tip of the Day. He also said, as others had, that he wished he had a way to contribute... and he wished there was a way to show his contribution, which is only fair. I like the idea of separating this blog from a much shorter Tip of the Day, where the TOD is, well, daily, and I also really like the idea of using Twitter as a MicroBlog. That was where inspiration came; let's put the four ideas together (a Tip of the Day, using Twitter for a Microblog, community contributions and recognition). Thus, Starting April 15 , The SLMicroBlog will merge with the Tip of the Day. Every day I'll publish a very short tip and to do so, I will depend heavily on contributions from Microsoft Employees and members of the Development community and readers of the blog. Starting immediately, please send your MicroBlog Contributions to jliberty@Microsoft.com as follows: 1. The Subject Line should be Tip of the Day 2. The Text for publication should be no more than 130 characters (including punctuation and spaces. Plain text. 3. Please append your 2-4 character alphanumeric signature (initials or whatever you like). I reserve the right to append numerals to disambiguate duplicates. 4. If you want public credit, please add a line at the bottom to the effect "You may match this signature to my name John Doe" -- if that line is present, I will update this blog entry with the name you send if/when I use your contribution. Thus, a typical email contribution might look like this: To jliberty@microsoft.com From: alex@alexHorovitz.com Subject: Tip of the Day Use the VerticalAlignment property to make your controls align within a grid's rows. AAH You may match AAH to Alex Horovitz. What would be published in the Microblog would be Use the VerticalAlignment property to make your controls align within a grid's rows. AAH At the bottom of this page would be Initials To Names AAH = Alex Horovitz Hope that is clear, and I look forward to your contributions. Let's give this a couple months and see if it is useful. Thanks. Attributions - last update 3/30/08 Initials to Names
  • Innovation, Renovation and Change

      So, after some minutes of trying this and that, it is time to take stock and see what's working and what isn't.  What's changing... Tip of the Day: RIP The Tip of the Day was a great idea, but I have yet to figure out what is the difference between a Tip of the Day and a blog entry, and I think it is causing more confusion than help, so I hereby kill it, put a stake through its heart, put a fork in it, bury it, liquidate it, drop a house on it. may it rest in peace. But only in name.   I still intend to post at least 5 days a week with substantive tips, follow ups, explorations of issues, and all the material I'd have put into a Tip of the Day; I'll just call them.... er... blog posts; like every body else.   The Micro Blog If I have your permission to stop experiments (like Tip of the Day) then I can experiment with truly wacky ideas. One, which was suggested to me in passing, I want to start right away: the Silverlight Microblog.  This is the idea of a blog that posts very frequently but only a line or two, and posts through Twitter . It is not a "here's what I'm doing" or even a "look here" reference to a bigger post somewhere else. Rather it is a complete blog entry in the 140 characters you are given.  This will take some practice. The Twitter account is SLMicroBlog and here's the first posting What needs clarification.... Tutorials: Not in Order The tutorials have been met with some enthusiasm, though it would be great to get more feedback and I invite you to send me email ( jliberty@microsoft.com ) or to post comments here. We're working on a way for you to post comments to the tutorials themselves. In any case, it is not my intention to write the tutorials in "order" -- I'm very aware that some folks would like to get to more advanced topics; though I do think it makes sense to go through most of the material at this level of depth before doing deep dives in the tutorials.  In addition, Scott Guthrie and I have agreed that the tutorials will be supplemented by the book I'm writing with Tim Heuer for O'Reilly (Programming Silverlight 2) which will provide more depth. Of course the book will be static, so after it publishes I'll continue to write tutorial pieces here as changes and new features emerge. Videos: Focus on:  Data and a mix of Intro and Advanced Topics Much like with the tutorials; it is my intention to move quickly back...
  • Tip of the Day: Routed Events - Bubbling and not...

    In Silverlight 2 Beta 1 some events bubble, and some do not. This can cause a bit of confusion, especially because the way this distinction is explained is itself confusing. To set the stage, let's examine the following simple event handling program which is extracted from my forthcoming video on Event handling (Parts 1 and 2) that will be posted to our Silverlight 2 video page . The example I'll be using is stripped down into a new application available here: TestRoutedEventsAndBubbling.zip Keeping The Example Simple To paraphrase A.E., an example should be as simple as possible, but no simpler. This example requires a control (in this case a button) whose content is not text, but rather other controls. These concepts are covered in the first two tutorials on Silverlight 2. We start by creating a new project and within that project a grid. The central control is a button whose Content is itself a StackPanel that contains 4 CheckBoxes The XAML for this is pretty straight forward and walked through in both the tutorials and the video, Notice in the XAML that we are looking at a single button that has a single content consisting of a stack panel within which are declared the four check boxes. The question is this: when you click on the check boxes, will the button be clicked? The answer is: it depends. If you wire this up with a click event it will not bubble. Let's prove that. This code adds a Click Event to the button. Sure enough, if you click anywhere on the button except the check box, the button is clicked as reflected in the count in the text box, but if you click in the check box, the check box is set or cleared but the count is unaffected. Now, when I check the documentation, I'm left a bit puzzled, after all, it does say that click is a Routed Event, And it does seem to suggested that Routed Events are, well, routed... The key is that there is routing and there is bubbling. Now, to make this a bit more confusing, you may read an explanation that goes something like this.... "User code cannot created routed events which the Button is doing" Eh? User code? Button? The key thing to realize is that from the perspective of the folks who wrote the code handling routing, the Button is user code (!) just like any control you or I would write. A sharp distinction is made between the fundamental events such as MouseLeftButtonDown which is an event on Implement and which does bubble You can prove this to yourself by modifying your code...
  • Tip of the Day - What to Expect in Silverlight Help

    I've received a lot of very positive feedback from the tutorials and videos and a lot of inquiries about what help will be forthcoming and how to get help right away. I thought I'd take a few minutes to provide some guidelines that are intended to optimize your experience, not to restrict your access... First, lots of folks are producing material, both on a regular and on an ad-hoc basis. If you are creating Silverlight 2 applications, I recommend subscribing to   Silverlight Community Blogs   Silverlight Geek Blog  (yah, that's me)   Tutorials As noted previously, the tutorials will be released at least twice monthly, beginning the end of this month, and my plan is to go through all of Silverlight 2 at an intermediate level.   Videos The videos will not be released in "order" -- that is to say the goal of the videos is for them to stand independently, allowing developers to dip into topics of interest. The first few will cover the basics, but after that I will be moving freely among elementary topics, intermediate and advanced topics.  Tips of the Day The tips of the day will range in size from one liners to full explorations of coding issues (with code examples attached) - often diving deeper into issues covered in the videos or the tutorials Blog Entries My blog entries will attempt to fill in the gaps, add a bit of a look behind the scenes and maintain some continuity in the story Web Casts The web casts will be a combination of deep dives and real-time HDI (How Do I) videos. The tentative schedule (soon to be finalized) looks like this: Date Topic 4/16 Controls and event handling 5/21 Data Binding/Routed Events 6/18 Styles, Templates and more 7/16 Deep Zoom   Looking for Help The best place to get the fastest answers is on the forum -- though I admit some questions slip through the cracks.  But the forums is where everyone looks first and if your question is unanswered for a while, post a follow up. The tricks to getting a fast answer include: a. Use a good subject that summarizes the problem so the folks who might know the answer stop and read the question. Good subject: "Urgent: Crashes when two buttons in same stack panel" - Bad subject "Help!!!!" b. Give as much information in as few words as possible - tell more, not less, but shorter paragraphs are easier to read, and put the important information up front; write like you're a journalist, not a novelist. c. Be very...
  • Tip of the Day: Getting Started With Silverlight 2

    A number of folks have asked me for a step by step set guide to getting started programming with Silverlight 2. Here it is. Useful tips Memorize this URL: http://silverlight.net - from there you can always find everything you need, including all the tools, tutorials, quick starts, videos, discussions, forums, demo programs, and much more Ignore and do not use anything marked Silverlight 1.1 - there are only two versions you care about as of now: Silverlight 1.0 (our release version) and Silverlight 2.0 (currently in Beta). How to Get Started 1. Navigate to Silverlight.net (did you memorize that URL?) and click on Silverlight 2 Beta 1 Now Available!   If that link has scrolled off the news you can start by clicking on Get Started on the standard menu,     If you click on Get Started follow that by clicking on View Other Versions , That will bring you to a link to the Silverlight 2 Beta 1 Runtimes. Click on that link.   These three steps from the standard menu will bring you to the same page as the one step from news,   Install the Silverlight runtime and when installed look in the upper right hand corner where you will want to click on Tools, That will bring you to a page full of tools. I've isolated the essential tools that you'll want to download or follow the links to in the next image, Note that this is not how the page appears; I've removed the inessential links and I'm showing only the ones you'll want to get started developing with Silverlight 2.   Getting Started Learning To Code Silverlight Applications There is a lot of information available for learning to code in Silverlight. Of course, I'll start by recommending that you read through the available Silverlight 2 Tutorials (I'll be adding a new tutorial twice each month) and watching the Silverlight 2 videos       and then finally, I'd return to the Learn page and work through any material related to Silverlight 2.   Don't forget about our Forums which are a great place to ask (and answer!) questions from other Silverlight programmers and Microsoft developers.       Be sure to check (or better, subscribe to!) the blogs (under Community)     That will make for a good start, and remember that lots of folks are adding new material every day; I personally will be adding two tutorials, half a dozen videos, a web cast and a couple dozen blog entries every month. So you'll want to stop by pretty...
  • How do I Write that In JavaScript?

    A comment was left in response to Master Detail in Silverlight 2 asking " Any hint how to create such a sample with Java Script instead C# ?" I thought the answer was important enough to post to the blog in general... Two points about your question. The first is whether you are asking if one can write this same program in JavaScript in Silverlight 2 (answer: yes) or you are asking if one can write the same program in Silverlight 1.0 (which only uses Javascript) (answer: depends). Second point is that there are a number of languages that SL2 supports: IronRuby, JavaScript, VB, C#, etc., and (frankly) it won't be possible for me to illustrate all of them (or even most of them) in these examples, but it shouldn't be terribly hard to translate the logic from one language to another because the code is pretty simple and the Silverlight documentation shows the syntax for each event, method and property in the various languages. While it is true that Silverlight 2 supports JavaScript, it is also true that C# supports language features that simply are not available in Javascript such as generics (ListOf<Books>) and true classes and objects. Translating my examples from C# to (e.g.,) VB is trivial, but translating to JavaScript is more of a challenge. Which brings me to my final point, which is that I honestly can't imagine why you'd want to do this in Javascript; the code will be slower, harder to maintain and harder to create. If you'll pardon what may sound rude and even arrogant, I think you'll be a lot happier if you take the opportunity to "step up" to managed code (see, for example, Programming C# 3.0, 5th Edition by my favorite author) which will not only enhance your Silverlight experience, but will bring you nicely into the entire spectrum of .NET programming from ASP.NET, ASP.NET/AJAX through WPF, WCF, Workflow, etc. Programming C# 3.0 (Programming) by Jesse Liberty, Donald Xie Read more about this title... You'll love it. I tried it in 2000 and never looked back.
  • Source for the Tip of the Day

    The Tip of the Day occasionally will delve deep into code (other days it will just provide a bit of useful information, or a tip, etc.) When code is examined, however, I'll try to provide a complete working example, and to get us started, I've gone backwards in time and added links to complete sample applications for Master Detail in Silverlight 2 (3/15) Content - It Ain't Just Text (3/11) Routed Events (3/10)   Each article now begins with a nice big link to the source code.   The source code should run well with the Beta 1 of Silverlight, but if you encounter any difficulties, please do let us know. Just for the record, every example is tested on the public release of Visual Studio 2008 and the public release version of Silverlight 2 Beta 1.
  • Tip of the Day - Binding to a Collection

    The Tip of the Day doesn't usually carry on a related series of postings, but data binding is so important that I'm making an exception this weekend. Yesterday we looked at laying out a form using a grid holding a DataGrid and a second grid to create a master detail relationship, with the end goal looking like this: To populate the DataGrid that we've placed in the left column of the outer grid, we'll need a collection of business objects. To keep this simple, I've returned to the idea of a book class, While it isn't strictly necessary for my Book class to implement INotifyPropertyChanged, it is convenient to have it do so, so that if the Book object is changed in the underlying data, the UI can be updated as well. Thus, each of the underlying private member fields  has a public property whose getter returns the private field and whose setter both sets the field and calls the Notify method to update the UI,   With the book class in place, it is easy to create a collection of Book objects based on the last few books I bought for my Kindle.  The steps are: Create a member variable to hold the collection Allocate memory for the collection Add objects to the collection Set the DataGrid to bind to properties of each individual object Set the collection as the ItemSource property of the DataGrid     Create a member variable to hold the collection Allocate memory for the collection Add objects to the collection You can imagine that we would normally be retrieving these objects from a database, web server, or other common data source. Here we are hand coding to keep life simple.       Set the DataGrid to bind to properties of each individual object   In this small snippet you can see that we've created an instance of the DataGrid, named it Books, placed it in the grid, and told it not to auto generate its columns (we only want two columns, not all of the properties of the Book!).  We then manually create two text box columns, one for the Title and one for the ISBN.   Set the collection as the ItemSource property of the DataGrid If you look closely at the line numbers you'll see that I cut out most of the "Add Book" calls to focus on the call to setting the ItemsSource on the DataGrid (look at line 23 in the previous image!).  By creating this binding, when the page loads the collection is bound to the data grid and the two properties from each book object are displayed...
  • Tip of the Day Returns from Disney - Master Detail in Silverlight 2

    Okay, its true, I was having so much fun at Disney World (and if you've not been on Soarin , then find a conference in Orlando, and sneak out to Soar, yowza!) that Tip of the Day kinda' sorta' stopped for a day or two. But we're back again with more in depth explorations of the tutorials, and responses to your email (which, I note did not slow down very much while I was on vacation, which is great!). So, today I'd like to lay out a schedule and a project and over the next couple days pursue that project and a few other topics as well. I've received quite a bit of email about data binding, and Tip of the Day seems like a good place to explore various aspects of this essential feature. I've created a relatively simple starter application that we can take apart, rebuild and then extend to explore various aspects of data binding; taking on other topics as we go.   This Silverlight application consists of an outer grid that has been divided into two columns. In the left column I've placed a DataGrid and in the right column I've placed an inner grid with details about whatever book is selected in the DataGrid.  There is plenty to do to make this look nicer, but for now I'd like to focus on the simple layout and the data binding. Here's the XAML that divides up the grids. I've collapsed the controls that populate the grids to make seeing the grids themselves somewhat easier, The outermost grid is defined on line 5 and named LayoutRoot. It serves as the container for everything and is defined as having the size 800x600 and having a background color of Bisque. This outer grid has one row (with a top and bottom margin). The rows are created on lines 11-15. On lines 16-22 are two columns, with two margins and a padding between the rows. The first column is fixed at 400 and the second column takes up the remaining space. The first row and first column is populated by a DataGrid which is shown collapsed on line 23 (we'll return to that shortly). The first row and third column (skipping one column for the padding) is a new grid named details. In essence, the DataGrid holds the listing of all the books, the details shows all the data about the selected book. The Details grid consists of six rows plus two margin rows, and two columns with padding between and a margin on either side. The left part of the details grid is set to 150, the right side gets all the remaining space (after allocation for the padding and...
  • Tip of the Day: More Ways To Learn Silverlight 2

    Yes, we have Silverlight 2 Videos and Yes we have Silverlight 2 tutorials But don't miss Tim Sneath's entry about his incredible Hands On Labs . These are gems.
  • Tip of the Day: Content - It Ain't Just Text

    In Silverlight 2, many of the controls have a content property where you might expect a text property. While it is common to fill that property with text, it isn't required that you do so. For example, you might create an application with two buttons...   The code begins by defining three rows, the first of which serves as a margin, and two columns, the first of which is a margin. The first button (red arrow) fills its content with text. Notice also that the first button is self closing. The second button (blue arrow) is not self closing. It is placed in the second row, and all the same attributes are set save one: the content. That will be set in the property element Button.Content Like matryoshka dolls To demonstrate the power and flexibility of what you can put into a content property, I'm going to fill the button's content with a stack panel that will in turn contain 3 controls: A text block with the word Play on the left A pair of radio buttons on the right that will be arranged in a stack panel and surrounded by a border In the middle will be a check box whose content will itself not be text, but rather will be a stack panel that will contain two radio buttons. But just to take this one step into the absurd, one of the radio buttons' content property will itself not be text but will be a Hyperlink button.  Here's what it looks like with both buttons in the grid, Let's build it up quickly so that we can get to that middle control. We begin with the declaration of the second button and its content property, In this block of code we see the second button declared and we see its content property opened. Within the content a stack panel is opened and declared to be horizontal so that the three controls will align next to one another rather than atop one another. The first of the three is a TextBlock, for which we set various attributes for the foreground color, margin, etc. The second element is a Checkbox declared on line 28, but which we surround with a Border on line 26, creating a bounding rectangle filled with a nice offsetting background color. Again, we use the Content property on line 32 to fill the check box with something other than text, The contents of the Checkbox consist of a stack panel (line 33) to hold the radio buttons (lines 36 and 42 one atop the other. The first radio button, however, fills its content on lines 36-40 with a HyperlinkButton which not only presents the word Loud but also provides a link...
  • Tip of the Day - Routed Events

    A routed event is is bubbled up the user interface tree whether or not it is handled by the object that receives the event. For example, if we return to a previous example in which we had a button within which were three sub-controls, the middle of which was a stack panel containing a check box whose content had another stack panel with two buttons, the first of which itself had content which was an html button... you can see that we want to be able to click on the radio button within the check box that is within the button and yet still have the click event bubble up and click the button. Yet, at the same time, we may want to respond to the click on the radio button or the check box being clicked. We saw the XAML for creating this control previously so there is no need to review that. It will be unchanged except that we'll want to add just one control for this example, and that is a list box that can hold messages indicating which control has registered the mouse down event, Note that to accommodate this helpful list box we need to add a row and a column to the grid, which is easily accomplished in our row and grid definitions at the top of the file, With that in place, we need only create event handlers to see how the events "bubble up" even as they are handled. Each of these event handlers is implemented to add a notice to the list box we added in the third column, If you click on an outer object (such as the check box border, only one event fires, Whereas if you click on an inner object (e.g., a radio button, you can see that the event is routed to the outer (containing) objects for handling as well. In this image, the user has clicked on the inner radio button. Because MouseLeftDown is a routed event, the event bubbles up through the UI tree, from the radio button to the check box to the surrounding border (and on up through the other surrounding UI elements that don't have event handlers!)
  • Tip of the Day - Great Silverlight Programmer utilities

    Personally, one of the reasons that I opted to move to Microsoft tools long ago  was I got tired of LightSpeed telling me that the problem was the debugger and Periscope telling me it was the editor, and XYWrite telling me it was the compiler and... well you get the idea.  Visual Studio 2008 is pretty amazing, but it isn't (yet) the end of software utilities for me, so here is my personal list of indispensable utilities for serious Silverlight programming. NB: the usual rules apply - these opinions are mine alone, your mileage may vary, no warranty is express or implied, contents are hot, opening or using of product may void warranty. 1. Video Capture. A lot of material is now available via video; some of it is even good; and some of that is free. If the following conditions apply to you:- Frequent access to videos (e.g., tutorials) that are legitimately yours to save to disk and A relatively high speed (broad band connection and } No easy way to save the video Then you really want to take a look at WM Recorder .  Truly great. 2. Exam Diff Pro - best software I know for examining differences in files and directories. Incredibly easy to use, to customize and very reliable. Great for those times when you're either not sure which file is the one with the critical change, for merging two branches or for figuring out what it is you did that finally fixed that bug! Finally, if you are going to do a presentation on Silverlight (or virtually anything else, you must have Mark Russinovich's Zoomit which is truly spectacular, and which you can used incredibly well in Scott Hanselman's presentation of MVC at Mix. Once you get comfortable with Zoomit, it offers a few features you won't find anywhere else, including (a) very focused zooming and (b) the ability to draw straight lines and real rectangles.
  • Tip of the Day: How the Silverlight Videos Are Made

    Creating A How Do I Video - Step By Step Let me bring you behind the scenes and tell you how I create a video. I'm very open to suggestions, but remember that my goal is to create great videos but to create six of them a month.. Decide what focused topic I'm going to demonstrate. The topic needs to be related to but build on something in the Silverlight Tutorials (these first few were too close to a repetition of what is in tutorials for my taste; the videos ought to extend the tutorials, not repeat them). Create an example program that illustrates the point I wish to make with sufficient complexity not to leave anything out but sufficient simplicity that the focus is clear and not obscured by programmer slight of hand. With the working example on monitor 1, set monitor 2 to 1024x768 and fire up Camtasia 5 . Key to good sound: adjust my Samson CO1U USB Condenser Mic sitting in its shock mount, placed on its floor stand. Set the balance equal at 80 and then use the Camtasia audio setting. Key to good video (for picture in picture): Adjust my Microsoft LifeCam (and one of these days follow Scott Hanselman's advice about cleaning up the clutter in my office!). 4. Set up all the programs I'll want to have appear in my video (typically Visual Studio, the Silverlight Help files, IE, etc. so that when "restored" they will open nicely in monitor #2, and set up the completed program in monitor #1. 5. Start recording, limiting the recording space to all of monitor #2 - do not use the wonderful utility Zoomit while recording - leave all zooming, callouts, etc. for post-production. 6. Turn picture in picture on and leave it on for the entire video (not to worry, we'll make me go away for most of the video, but we'll do that post-production; fortunately Camtasia has that on a separate track. (Total set up time is about 1-2 hours) 7. Set up 30 frames per second (the videos up there now have 5-15 fps which is why the picture in picture is so poor!) 8. Record the video. Shoot for 30-40 minutes. Keep an eye on it; it is easy to go twice that! 9 Save the project and get ready to edit. Be sure to restore monitor #2 to full size (Total Recording time is about 1 Hour) 10.. Two monitor editing, with the image on one monitor and the timeline/editor on the second. Edit with a light touch. 11. Leave minor errors in. Take egregious errors out. Take long waits out (e.g, waiting for Visual studio to set up, waiting for the program to run the first time...
More Posts Next page »