BusinessRx Community

Dedicated to the advancement of software, technology and the people who devote their lives to it.

Welcome to BusinessRx Community Sign in | Join | Help
in Search

BusinessRx Reading List

These blog entries are written by industry experts and leaders. We consider this content to be a good read for any software developer or web technologist.

Browse by Tags

All Tags » Visual Studio   (RSS)

  • jQuery and Microsoft

    jQuery is a lightweight open source JavaScript library (only 15kb in size) that in a relatively short span of time has become one of the most popular libraries on the web.

    A big part of the appeal of jQuery is that it allows you to elegantly (and efficiently) find and manipulate HTML elements with minimum lines of code.  jQuery supports this via a nice "selector" API that allows developers to query for HTML elements, and then apply "commands" to them.  One of the characteristics of jQuery commands is that they can be "chained" together - so that the result of one command can feed into another.  jQuery also includes a built-in set of animation APIs that can be used as commands.  The combination allows you to do some really cool things with only a few keystrokes.

    For example, the below JavaScript uses jQuery to find all <div> elements within a page that have a CSS class of "product", and then animate them to slowly disappear:

    As another example, the JavaScript below uses jQuery to find a specific <table> on the page with an id of "datagrid1", then retrieves every other <tr> row within the datagrid, and sets those <tr> elements to have a CSS class of "even" - which could be used to alternate the background color of each row:

    [Note: both of these samples were adapted from code snippets in the excellent jQuery in Action book]

    Providing the ability to perform selection and animation operations like above is something that a lot of developers have asked us to add to ASP.NET AJAX, and this support was something we listed as a proposed feature in the ASP.NET AJAX Roadmap we published a few months ago.  As the team started to investigate building it, though, they quickly realized that the jQuery support for these scenarios is already excellent, and that there is a huge ecosystem and community built up around it already.  The jQuery library also works well on the same page with ASP.NET AJAX and the ASP.NET AJAX Control Toolkit.

    Rather than duplicate functionality, we thought, wouldn't it be great to just use jQuery as-is, and add it as a standard, supported, library in VS/ASP.NET, and then focus our energy building new features that took advantage of it?  We sent mail the jQuery team to gauge their interest in this, and quickly heard back that they thought that it sounded like an interesting idea too.

    Supporting jQuery

    I'm excited today to announce that Microsoft will be shipping jQuery with Visual Studio going forward.  We will distribute the jQuery JavaScript library as-is, and will not be forking or changing the source from the main jQuery branch.  The files will continue to use and ship under the existing jQuery MIT license.

    We will also distribute intellisense-annotated versions that provide great Visual Studio intellisense and help-integration at design-time.  For example:

    and with a chained command:

    The jQuery intellisense annotation support will be available as a free web-download in a few weeks (and will work great with VS 2008 SP1 and the free Visual Web Developer 2008 Express SP1).  The new ASP.NET MVC download will also distribute it, and add the jQuery library by default to all new projects.

    We will also extend Microsoft product support to jQuery beginning later this year, which will enable developers and enterprises to call and open jQuery support cases 24x7 with Microsoft PSS.

    Going forward we'll use jQuery as one of the libraries used to implement higher-level controls in the ASP.NET AJAX Control Toolkit, as well as to implement new Ajax server-side helper methods for ASP.NET MVC.  New features we add to ASP.NET AJAX (like the new client template support) will be designed to integrate nicely with jQuery as well. 

    We also plan to contribute tests, bug fixes, and patches back to the jQuery open source project.  These will all go through the standard jQuery patch review process.

    Summary

    We are really excited to be able to partner with the jQuery team on this.  jQuery is a fantastic library, and something we think can really benefit ASP.NET and ASP.NET AJAX developers.  We are looking forward to having it work great with Visual Studio and ASP.NET, and to help bring it to an even larger set of developers.

    For more details on today's announcement, please check out John Resig's post on the jQuery team blog.  Scott Hanselman is also about to post a nice tutorial that shows off integrating jQuery with ASP.NET AJAX (including the new client templating engine) as well as ADO.NET Data Services (which shipped in .NET 3.5 SP1 and was previously code-named "Astoria").

    Hope this helps,

    Scott

  • Silverlight 2 Release Candidate Now Available

    This evening we published the first public release candidate of Silverlight 2.

    There are still a small handful of bugs fixes that we plan to make before we finally ship.  We are releasing today's build, though, so that developers can start to update their existing Silverlight Beta2 applications so that they'll work the day the final release ships, as well as to enable developers to report any last minute showstopper issues that we haven't found internally (please report any of these on the www.silverlight.net forums).

    Important: We are releasing only the Silverlight Developer Runtime edition (as well as the VS and Blend tools to support it) today, and are not releasing the regular end-user edition of Silverlight.  This is because we want to give existing developers a short amount of time to update their applications to work with the final Silverlight 2 APIs before sites are allowed to go live with it.  There are some breaking changes between Beta2 and this RC, and we want to make sure that existing sites can update to the final release quickly once the final release is out.  As such, you can only use the RC for development right now - you can't go live with the new APIs until the final release is shipped (which will be soon though).

    You can download today's Silverlight Release Candidate and accompanying VS and Blend support for it here.  Note that Expression Blend support for Silverlight 2 is now provided using Blend 2.0 SP1.  You will need to install Blend 2.0 before applying the SP1 service pack that adds Silverlight 2 support.  If you don't already have Blend 2.0 installed you can download a free trial of it here.

    Beta2->RC API Updates

    Today's release candidate includes a ton of bug fix and some significant performance optimization work.

    Today's release candidate also includes a number of final API tweaks designed to fix differences between Silverlight and the full .NET Framework.  Most of these changes are relatively small (order of parameters, renames of methods/properties, movement of types across namespaces, etc) although there are a number of them.  You can read this blog post and download this document to get a listing of the known API breaking changes made from the Beta2 release. 

    We have updated the styles of the controls shipped with Silverlight, and have also modified some of the state groups and control template names they use.  When upgrading from Beta2 you might find it useful to temporarily remove any custom style templates you've defined, and get your application functionality working using the RC first - and then after that works add back in the styles one style definition at a time to catch any rename/behavior change issues with them.

    If you find yourself stuck with an question/issue moving from Beta2 to the RC, please report it on the www.silverlight.net forums (Silverlight team members will be on there helping folks).  If after a day or two you aren't getting an answer please send me email (scottgu@microsoft.com) and I can help or connect you with someone who knows the answer.

    New Controls

    Today's release candidate includes a bunch of feature additions and tweaks across Silverlight 2, as well as in the VS and Blend tools targeting it. In general you'll find a number of nice improvements across the controls, networking, data caching, layout, rendering, media stack, and other components and sub-systems.

    Over the next few months we will be releasing a lot of new Silverlight 2 controls (more details on these soon).  Today's release candidate includes three new core controls - ComboBox, ProgressBar, and PasswordBox - that we are adding directly to the core Silverlight runtime download (which is still only 4.6MB in size, and only takes a few seconds to install):

    At runtime these controls by default look like:

    The ComboBox in Silverlight 2 supports standard DropDownList semantics.  In addition to statically defining items like above, you can also use databinding with it.  For example, we could define a "Person" class like below:

    And the add a ComboBox to a page like so:

    And then write the below code to databind a collection of Person objects to the ComboBox (by setting its ItemSource property):

    At runtime our simple app will then display the data-bound Person names (note that we set the DisplayMemberPath property on the ComboBox above to display the "Name" value from our Person objects):

    We could then implement a SelectionChanged event handler like below to run code when a person is selected from the ComboBox:

    Notice above how we can retrieve a reference to the selected "Person" object from the databound ComboBox using the ComboBox's "SelectedItem" property. 

    We can then call the MessageBox.Show() helper method (new in the RC) to display a modal dialog box that displays some details about our selected person:

     

    New Control Skins

    The final release of Silverlight 2 will have a much more polished set of default control template skins than those that were in Beta1 and Beta2.  Our goal with the default control templates is to have a look that is professional and attractive, can be used in the majority of applications as-is (without requiring you to author custom style templates), and which is also easily tweakable using Expression Blend.

    Today's RC build has skins that are close to the final look we plan to ship (there are a few final tweaks we are doing post RC on the focus color of controls, as well as to tighten up and tweak a few issues in some of the control templates).  Below is the default look for the DataGrid, RadioButton, CheckBoxes, and the DatePicker controls with today's RC build:

    Note that the DatePicker control above allows users to type in a date (with a masked edit to ensure it is a valid date), or they can click the calendar icon to the right of the textbox and select the date using a popup Calendar control:

    One of the most powerful features of Silverlight and WPF, of course, is the ability for designers and developers to completely customize the look and feel of any control.  This goes beyond simple styling of colors and fonts - you can literally completely change the visual UI of a control, as well as customize its behavior (for example: add animation) without writing any code.

    Within Expression Blend, simply right-click on any Silverlight control and choose the "Edit Control Parts" sub-menu to open and edit its control template:

     

    When in control template editing mode, you can manipulate any sub-element of a control (for example: a checkbox's inner content), as well as customize each "state" its in (notice the states pane circled in red below).  This allows designers to customize what the control looks like in individual states (for example: checked, unchecked, mouseover, etc).  Silverlight will then automatically handle animating the control from state to state depending on the user action:

    You can learn more about how Silverlight's Visual State Model works from my previous blog post here

    Previous releases of Silverlight often rendered graphics on sub-pixel locations - which could cause lines and shapes to sometimes appear "fuzzy".  The RC of Silverlight has a new features called "layout rounding" that causes the layout system to round the final measure of a control to an integer ("pixel snapping"), which results in crisper lines and fewer rendering artifacts.  This feature is now on by default, and helps make applications look nicer.

    Summary

    The final release of Silverlight is not that far off now.  It has been a pretty amazing project that has come a long way in a pretty short amount of time.

    If you have existing Beta2 applications, please start getting them ready for the final release - as once we release Silverlight 2, users that have existing beta releases installed will automatically be upgraded to use the final version.  Testing your application out with the release candidate will ensure that you can easily update your applications and have them ready within hours of the final release.

    Let us know if you find issues with today's release candidate, and please make sure to post them on the forums on http://www.silverlight.net.

    Hope this helps,

    Scott

  • ASP.NET MVC Preview 4 Release (Part 1)

    The ASP.NET MVC team is in the final stages of finishing up a new "Preview 4" release that they hope to ship later this week.  The Preview 3 release focused on finishing up a lot of the underlying core APIs and extensibility points in ASP.NET MVC.  Starting with Preview 4 this week you'll start to see more and more higher level features begin to appear that build on top of the core foundation and add nice productivity.

    There are a bunch of new features and capabilities in this new build - so much in fact that I decided I needed two posts to cover them all.  This first post will cover the new Caching, Error Handling and Security features in Preview 4, as well as some testing improvements it brings.  My next post will cover the new AJAX features being added with this release as well.

    Understanding Filter Interceptors

    Action Filter Attributes are a useful extensibility capability in ASP.NET MVC that was first added with the "Preview 2" release.  These enable you to inject code interceptors into the request of a MVC controller that can execute before and after a Controller or its Action methods execute.  This enables some nice encapsulation scenarios where you can easily package-up and re-use functionality in a clean declarative way.

    Below is an example of a super simple "ScottGuLog" filter that I could use to log details about exceptions raised during the execution of a request.  Implementing a custom filter class is easy - just subclass the "ActionFilterAttribute" type and override the appropriate methods to run code before or after an Action method on the Controller is invoked, and/or before or after an ActionResult is processed into a response.

    Using a filter within a ASP.NET MVC Controller is easy - just declare it as an attribute on an Action method, or alternatively on the Controller class itself (in which case it will apply to all Action methods within the Controller):

    Above you can see an example of two filters being applied.  I've indicated that I want my "ScottGuLog" to be applied to the "About" action method, and that I want the "HandleError" filter to be applied to all Action methods on the HomeController.

    Previous preview releases of ASP.NET MVC enabled this filter extensibility, but didn't ship with pre-built filters.  ASP.NET Preview 4 now includes several useful filters for handling output caching, error handling and security scenarios.

    OutputCache Filter

    The [OutputCache] filter provides an easy way to integrate ASP.NET MVC with the output caching features of ASP.NET (with ASP.NET MVC Preview 3 you had to write code to achieve this). 

    To try this out, modify the "Message" value set within the "Index" action method of the HomeController (created by the VS ASP.NET MVC project template) to display the current time:

    When you run your application you'll see that a timestamp updates each time you refresh the page:

    We can enable output caching for this URL by adding the [OutputCache] attribute to the our Action method.  We'll configure it to cache the response for a 10 second duration using the declaration below:

    Now when you hit refresh on the page you'll see that the timestamp only updates every 10 seconds.  This is because the action method is only being called once every 10 seconds - all requests between those time intervals are served out of the ASP.NET output cache (meaning no code needs to run - which makes it super fast).

    In addition to supporting time duration, the OutputCache attribute also supports the standard ASP.NET output cache vary options (vary by params, headers, content encoding, and custom logic).  For example, the sample below would save different cached versions of the page depending on the value of an optional "PageIndex" QueryString parameter, and automatically render the correct version depending on the incoming URL's querystring value:

    You can also integrate with the ASP.NET Database Cache Invalidation feature - which allows you to automatically invalidate the cache when a database the URL depends on is modified (tip: the best way to-do this is to setup a CacheProfile section in your web.config and then point to it in the OutputCache attribute). 

    HandleError Filter

    The [HandleError] filter provides a way to declaratively indicate on a Controller or Action method that a friendly error response should be displayed if an error occurs during the processing of a ASP.NET MVC request. 

    To try this out, add a new "TestController" to a project and implement an action method that raise an exception like below:

    By default when you point your browser at this URL, it will display a default ASP.NET error page to remote users (unless you've gone in and configured a <customErrors> section in your web.config file):

    We can change the HTML error displayed to be a more friendly end-user message by adding a [HandleError] attribute to either our Controller or to an Action method on our Controller:

    The HandleError filter will catch all exceptions (including errors raised when processing View templates), and display a custom Error view response when they occur.  By default it attempts to resolve a View template in your project called "Error" to generate the response.  You can place the "Error" view either in the same directory as your other Controller specific views (for example: \Views\Test for the TestController above), or within the \Views\Shared folder (it will look first for a controller specific error view, and then if it doesn't find one it will look in the shared folder - which contains views that are shared across all controllers).

    Visual Studio now automatically adds a default "Error" view template for you inside the \Views\Shared folder when you create new ASP.NET MVC Projects starting with Preview 4:

    When we add a [HandleError] attribute to our TestController, this will by default show remote users an html error page like below (note that it picks up the master page template from the project so that the error message is integrated into the site).  You can obviously go in and customize the Error view template to display whatever HTML and/or friendlier customer error message you want - below is simply what you get out of the box:

    To help developers, the default Error view template provided by the new project template in Visual Studio is written to display additional error stack trace information when you are browsing the application locally:

    You can turn this off either by deleting the code from the Error view template, or by setting <customErrors> to "off" inside your web.config file.

    By default the [HandleError] filter will catch and handle all exceptions that get raised during the request.  You can alternatively specify specific exception types you are interested in catching, and specify custom error views for them by specifying the "ExceptionType" and "View" properties on [HandleError] attributes:

    In the code above I'm choosing to display custom error views for SqlExceptions and NullReferenceExceptions.  All other exceptions will then use the default "Error" view template.

    Authorize Filter

    The [Authorize] filter provides a way to declaratively control security access on a Controller or Action method.  It allows you to indicate that a user must be logged in, and optionally require that they are a specific user or in a specific security role in order to gain access.  The filter works with all types of authentication (including Windows as well as Forms based authentication), and provides support for automatically redirecting anonymous users to a login form as needed.

    To try this out, add an [Authorize] filter to the "About" action in the HomeController created by default with Visual Studio:

    Declaring an [Authorize] attribute like above indicates that a user must be logged into the site in order for them to request the "About" action.  When non-logged-in users attempt to hit the /Home/About URL, they will be blocked from gaining access.  If the web application is configured to use Windows based authentication, ASP.NET will automatically authenticate the user using their Windows login identity, and if successful allow them to proceed.  If the web application is configured to use Forms based authentication, the [Authorize] attribute will automatically redirect the user to a login page in order to authenticate (after which they'll have access):

    The [Authorize] attribute optionally allows you to grant access only to specific users and/or roles.  For example, if I wanted to limit access to the "About" action to just myself and Bill Gates I could write:

    Typically for all but trivial applications you don't want to hard-code user names within your code.  Instead you usually want to use a higher-level concept like "roles" to define permissions, and then map users into roles separately (for example: using active directory or a database to store the mappings).  The [Authorize] attribute makes it easy to control access to Controllers and Actions using a "Roles" property:

    The [Authorize] attribute does not have a dependency on any specific user identity or role management mechanism.  Instead it works against the ASP.NET "User" object - which is extensible and allows any identity system to be used.

    AccountController Class

    I mentioned above that the [Authorize] attribute can be used with any authentication or user identity management system.  You can write or use any custom login UI and/or username/password management system you want with it.

    To help you get started, though, the ASP.NET MVC Project Template in Visual Studio now includes a pre-built "AccountController" and associated login views that implement a forms-authentication membership system with support for logging in, logging out, registering new users, and changing passwords.  All of the views templates and UI can be easily customized independent of the AccountController class or implementation:

    The Site.master template also now includes UI at the top-right that provides login/logout functionality.  When using forms-based authentication it will prompt you to login if you are not currently authenticated:

    And it displays a welcome message along with a logout link if you are authenticated on the site:

    Clicking the Login link above takes users to a Login screen like below that they can use to authenticate:

    New users can click the register link to create new accounts:

    Error handing and error display is also built-in:

    The AccountController class that is added to new projects uses the built-in ASP.NET Membership API to store and manage user credentials (the Membership system uses a provider API allowing any back-end storage to be plugged-in, and ASP.NET includes built-in providers for Active Directory and SQL Server).  If you don't want to use the built-in Membership system you can keep the same AccountController action method signatures, View templates, and Forms Authentication ticket logic, and just replace the user account logic within the AccountController class.  For the next ASP.NET MVC preview release we are planning to encapsulate the interaction logic between the AccountController and the user identity system behind an interface - which will make it easier to plug-in your own user storage system (without having to implement a full membership provider) as well as to easily unit test both it and the AccountController.

    Our hope is that this provides a nice way for people to quickly get started, and enable them to have a working end to end security system as soon as they create a new project.

    Testing TempData

    One last improvement to touch on in this first preview 4 post is some improvements being made on the Controller class that allow you to more easily unit test the TempData collection.  The TempData property allows you to store data that you want to persist for a future request from a user.  It has the semantic of only lasting one future request (after which it is removed).  It is typically used for MVC scenarios where you want to perform a client-side redirect to change the URL in the browser, and want a simple way to store scratch data.

    With previous ASP.NET MVC Previews you had to mock objects in order to test the TempData collection.  With Preview 4 you no longer need to mock or setup anything.  You can now add and verify objects within the Controller's TempData collection directly within your unit tests (for example: populate a controller's TempData property before calling its action method, or verify that the action updated the TempData after the action returned).  The actual storage semantics of the TempData collection is now encapsulated within a separate TempDataProvider property. 

    Conclusion

    Hopefully the above post provides a quick look at a number of the new features and changes coming with ASP.NET MVC Preview 4.  My next post on ASP.NET MVC Preview 4 will cover the new AJAX functionality that has been added, and demonstrate how to take advantage of it.

    Hope this helps,

    Scott

  • Silverlight 2 Beta2 Released

    Silverlight 2 Beta2 was released today.  You can download both Silverlight 2 Beta2 and the Visual Studio and Expression Blend tools support to target it here.

    Beta2 adds a lot of new features (more details below), but is still a 4.6 MB download that takes less than 10 seconds to install on a machine.  It does not require the .NET Framework or any other software to be installed for it to work, and all features work cross-browser on both Mac and Windows machines.  These features will also be supported on Linux via the Moonlight 2 release.

    Silverlight 2 Beta2 supports a go-live license that allows you to start using and deploying Silverlight 2 for commercial applications. There will be some API changes between Beta2 and the final release, so you should expect that applications you write with Beta2 will need to make some updates when the final release comes out.  But we think that these changes will be straight-forward and relatively easy, and that you can begin planning and starting commercial projects now.

    You can build Silverlight Beta2 applications using the VS 2008 Tools for Silverlight and Expression Blend 2.5 June Preview downloads.  You can download both of them here.  The VS 2008 Tools for Silverlight download works with both VS 2008 and the recent VS 2008 SP1 beta release. 

    UI and Control Improvements

    Silverlight 2 Beta2 includes a bunch of work in the UI and Control space:

    More Built-in Controls

    In Beta 1 only a few controls were included with the core Silverlight setup.  Most common controls (including Button, ListBox, Slider, etc) were shipped within separate assemblies that you had to bundle with your applications (which increased the app download size).  Beta 2 now installs 30+ of the most common controls as part of the core Silverlight 2 download.  This means that you can now build Silverlight 2 applications that use core controls that are as small as 3kb in size - making Silverlight application downloads small and startup time fast.

    In addition to the core controls included with the base Silverlight 2 setup, we are also this week shipping additional higher-level controls that are implemented in separate assemblies that you can then reference and include with your applications.  This includes controls like DataGrid (more details on its new Beta2 features below), Calendar (now with multi-day selection and blackout date support in Beta2), and a TabPanel control (new in Beta2).

    We ultimately expect to ship over a 100 controls for Silverlight.

    Control Template Editing Support

    One of the most powerful features of the WPF and Silverlight programming model is the ability to completely customize the look and feel of controls.  This allows developers and designers to sculpt the UI of controls in both subtle and dramatic ways, and enables a tremendous amount of flexibility.  I covered these concepts a little in my previous Silverlight Control Templating blog post here.

    This week's Expression Blend 2.5 June Preview now adds designer support for editing control templates - which makes it easy for you to quickly change the look of any control without having to drop-down to XAML source to-do it. 

    To see control template editing in action, just drag/drop two Slider controls onto the Expression Blend design surface:

    We might decide that the slider head in the default Slider control template is too large and wide for our application.  To use control template editing to change it, we can right-click on one of the sliders in the designer and select the "Edit Control Parts" context menu item.  We can choose to create a new empty control template for our slider (and start from scratch), or alternatively edit a copy of the built-in control template (and start from that and tweak it):

    After we choose to edit a copy of the existing control template, Blend will prompt us to create and name a re-usable style resource that we'll define our control template within.  We can name it and then choose to store the style at either the application level (within App.xaml) or within our current page/user-control:

    When we click "ok" we'll find ourselves in template editing mode for our Slider control.  We can change, tweak, or add/remove any of the underlying elements within the Slider control's template.  Notice below how in template editing mode we can see and select any of the underlying elements that make up the slider's control template (these are circled in red below in the "Objects" window). 

    To make our slider head narrower, we can select the "HorizontalThumb" element within the control template and adjust its width (either graphically or via the property grid): 

    We can then use the breadcrumb navigation bar at the top of the designer to navigate back to our page and see the control template changes applied:

    Notice that right now only one of our slider controls is using the new Style resource with the control template we defined. 

    To apply the same style resource to the other slider control as well, we can select it, right-click, and then use the "Apply Resource" context menu to apply our "ScottSlider" style to it as well:

    Once we do this both our sliders reference the same style:

    Changes we make to the "ScottSlider" style going forward will automatically apply to both controls.

    Note that all controls shipped with Silverlight 2 support control templates and will support the above editing experience in Expression Blend.

    Visual State Manager (VSM) Support

    Control templates in Silverlight and WPF support customizing both the "look" of a control, as well as the "feel" of a control.  By "feel" I mean changing its interactive responsiveness.  For example: how it reacts when pushed, when it gets focus, loses focus, is in a pushed state, is in a disabled state, has something inside it selected, etc.  Often you want animations to execute when the user interacts with a control like this.

    One of the new things we are introducing with Silverlight 2 Beta2 is a "Visual State Manager" (VSM) feature that makes it much easier to build interactive control templates.  VSM introduces two basic concepts that you can take advantage of within control templates: "Visual States" and "State Transitions".  For example, a control like Button defines multiple visual states for itself - "Normal", "MouseOver", "Pressed", "Disabled", "Focused", "Unfocused".   When in template editing mode in Blend, designers now have the ability to easily edit what the button looks like in each particular state, as well as setup transition rules to control how long it should take to animate when moving from one state to another.  At runtime Silverlight will then dynamically run the appropriate animation Storyboards to smoothly move the control from one state to another.

    What is nice about this model is that designers do not need to write code, do not need to manually create animation storyboards, and do not need to understand the object model of controls in order to be productive.  This makes the learning curve for creating interactive control templates really easy, and means that existing graphic designers can very easily work on Silverlight projects.  Later this year we will also be adding Visual State Manager (VSM) support to WPF as well, which will let you use the same approach with Windows applications as well as share control templates between WPF and Silverlight projects.

    To see an example of this in action, let's add a Button control onto our design surface:

    We can then right click on the button and edit its control template. Instead of starting with the existing default control template (like we did with the slider example above), let's create an empty control template and start from scratch:

    Blend will prompt us for the name of the Style resource we want to create.  We'll name it "ScottButton" and click ok.  This will then put the designer in control editing mode for the Button, and start with an empty control template:

    One of the things to notice above is the new "States" window inside Blend.  This will show us all of the available "Visual States" that the Button control exposes.  Above the "Base" state is currently selected - which allows us to define the common visual tree of our Button control template. 

    We can then add some vector elements into our base state that defines the look of a custom button like below.  We could use the built-in vector drawing tool support provided by Blend to author these graphics, or alternatively use Expression Design or Adobe Illustrator to build the vector art and then import it into Blend.  Below we are adding 4 "Path" elements into our control template - one a rounded background (named "background"), one a drop shadow (named "shadow"), one a 40% opacity "shine" that adds a glow near the top, and one that defines the default inner content (in this case a picture of a house):

    Note: we could have alternatively imported an image, but using vector elements will give us the flexibility to scale/stretch/transform the button later and retain a crisp look and feel at any resolution or scale (particularly useful with Silverlight mobile scenarios - where screen resolutions might be different or smaller).  It will also allow us to easily animate/change any vector element within the artwork.

    Once we've finished designing our base state above, we can press F5 to run our application in the browser:

    As you can see above - our Button control now has a nicer look.  Despite its new look, the button still raises the same focus, click and hover events just like before - so a developer using the button does not need to change any code when working with a button that uses our new control template.

    One downside with our new button control template, though, is that it isn't interactive.  This means that I don't get any visual feedback if the button gains/looses focus, or if a mouse hovers over it.  I also don't get a nice depress/bounce-back animation when I click it.

    To add interactivity to our button, we'll return back to Blend and work with our Button's control template again.  Previously we added vector graphic elements to the "Base" state of our Button control.  This allowed us to define the default visual look of all visual states of our Button.  We can now go back and customize individual Button visual states further.

    For example, to implement a mouse-over behavior for our Button, we can select the "MouseOver" state in the "States" window, and then tweak the look of the button when it is in that state.  Below I've selected the "shine" vector element inside our control template and adjusted its Opacity property in the property grid to have it be more visible when in the MouseOver state.  Notice how Blend automatically highlighted the "Shine" element with a red dot and then listed the Opacity property below it in our objects window.  This makes it easy to quickly track all changes that we've made between the "Base" state and the "MouseOver" state in our control template:

    We can then select the "Pressed" state in the "States" window, and customize what a button looks like when it is pressed.  We'll change two things from the "base" state.  The first change is to make the "shine" element visible (like the MouseOver state). The second change will be to slightly offset the contents of the button control - while keeping the shadow element stationary.  This will give the button a nice "depressed" look and contrast nicely with its base visual:

    We can implement the offset change to the background, content and shine elements by selecting them in the designer, and then apply an offset render transform to them in the property browser:

    And now when we run our application again in the browser, we'll find that our Button now has interactive visual feedback when it is being used.  Below is the "normal" look of our Button:

    Hovering the mouse over the Button will then cause it to glow like below:

    Clicking the button will then cause it to depress and hide the shadow (it will then bounce back once the mouse button is released):

    Note that we did not have to write any code or XAML to change our Button's look and feel - the new Visual State Manager feature automatically handled moving between visual states for us. 

    By default Silverlight dynamically constructs and runs a transition Storyboard for you as you move from visual state to visual state (providing a smooth animation between the two states).  You do not need to write any code in order to make this happen (note: you do still have the ability to drop down and add a custom Storyboard transition if you want to, but for most cases you can probably use the automatic Storyboard transition).

    One feature you can take advantage of with Silverlight's automatic transition feature is to customize the time duration it takes for a visual state transition to occur.  You can do this by clicking the arrow to the right of a visual state and setup a rule that controls how long it should take the transition animation to run when moving from one particular state to another.

    For example, we could indicate that we want it to take .2 seconds to transition from the "Normal" to "MouseOver" visual state by adding the rule below:

    We can then configure this rule to take .2 seconds to transition between Normal->MouseOver like so:

    We can then click on the "MouseOver" state and setup a rule that causes the transition from MouseOver->Normal to take .4 seconds:

    Now when we re-run our application we'll have slower animation transitions for MouseOver scenarios, which adds a slightly smoother and more polished feel to our application.  We did not have to write a single line of code to enable this.  All controls shipped with Silverlight 2 will have built-in support for Control Template and Visual State Manager customization like above.

    To learn more about the new Visual State Manager and Control Template Editing features, please check out the tutorials here and here, and the videos on it here, here, and here.

    TextBox

    Beta2 includes some significant improvements to the built-in TextBox editing control.  Text scrolling with text-wrap, multi-line text selection, document navigation keys, and copy/paste from the clipboard are now supported.

    Beta2 also now includes IME Level 3 input support (including candidate window selection) for non-western character sets:

    Input Support

    Beta2 adds additional keyboard support in FullScreen mode (arrow, tab, enter, home, end, pageup/pagedown, space).  Note: full key input support isn't allowed to avoid password spoofing scenarios.

    Beta2 also adds new APIs to support inking and stylus input support.

    UI Automation and Accessibility

    Beta2 adds UI Automation Framework support into Silverlight.  UI Automation (or UIA) enables screen readers and other assistive tools to identify and interact with the components that make up your Silverlight 2 application.

    Beta2 uses the UIA framework and adds UIA based behaviors to an initial set of Silverlight controls.  By the final release of Silverlight 2 all controls will have UIA based behaviors built-in.  We will also add support for high-contrast scenarios.  These features will enable you to build accessible, section 508 compliant, applications.  This UIA support will also enable automated UI testing of applications.

    Animation and Graphic System

    Beta2 adds support for animating custom dependency properties.  Object animation support (animating structs) is also now supported.  Beta2 also supports the ability to create Storyboards in code that can animate parts of the render tree without having to be added to it (allowing you to embed animations entirely in code).  Per frame animation callback support will be added in the final release.

    Beta2 includes a new Visual Tree Helper static class that provides advanced visual tree inspection APIs.  It provides features such as the ability to enumerate children of an element and getting the ancestor/parent of a given reference element.  These APIs work against any UIElement you pass to it.

    DeepZoom

    Beta2 now supports an XML based manifest file for DeepZoom collections.  Beta2 also adds extensible MultiScaleTileSource support for DeepZoom (which allows developers to hook up existing image pyramids that don’t conform with the Deep Zoom format to the high performance rendering of Deep Zoom).

    WPF Compatibility

    Silverlight Beta2 includes a lot of fixes/changes to improve API compatibility between Silverlight and WPF (note: the final Silverlight release will contain some additional compatibility work as well).  We are also adding some new APIs we are introducing in Silverlight 2 to WPF in .NET 3.5 SP1 this summer.

    This work, combined with the VSM support we are adding to WPF later this year, will enable good code re-use across browser and desktop applications.

    Media Improvements

    Silverlight 2 Beta2 includes some significant Media related feature work:

    Adaptive Streaming

    Beta2 adds support for "adaptive streaming" - which enables you to encode media at multiple bit-rates and then have a Silverlight application dynamically switch between them depending on the network and CPU conditions.

    This enables much richer end-user media experiences - since it makes it possible for content providers to provide both lower-end and higher-end bit rate versions of a video, and then have Silverlight choose the optimal one to use based on an end-user's machine hardware and network capacity.  If while watching the video the machine or network conditions change, Silverlight can automatically switch to a more appropriate bit-rate without any buffering or interruption glitch.

    Silverlight's support for adaptive streaming is extensible - which enables anyone to plug-in their own logic to control where the media content comes from, and what bit-rate should be used.  This means that any CDN or media delivery provider can easily integrate their systems with Silverlight and deliver super high quality video delivery.

    Content Protection

    Beta2 includes DRM content protection, and supports Windows DRM and PlayReady DRM.  Both work cross browser and cross platform.

    Server Side Playlists

    Beta2 adds support for server side playlists (previous releases only supported client-side playlists). 

    Networking Improvements

    Silverlight 2 Beta2 includes a bunch of work in the networking space:

    Cross Domain Sockets

    Beta2 now enables cross domain networking support using both HTTP and Sockets (meaning your application can call sites other than the one the application was downloaded from).

    Silverlight will check for the existence of an XML policy file on target servers that indicates whether cross domain network access is allowed.  Silverlight supports a new XML policy file format that we've developed, as well as Flash policy files (which means existing sites open to Flash can be called from Silverlight without any additional work).

    Background Thread Networking

    Beta2 now allows Silverlight applications to initiate network requests on background threads, as well as process/handle network responses on background threads.  This enables a bunch of powerful scenarios, and allows you to avoid blocking the browser's UI thread while doing both HTTP and Socket network communication.

    Duplex Communication (Server Push)

    Beta2 enables support for setting up duplex communication channels with a WCF service on a server.  This enables a clean programming model that allows servers to "push" messages to Silverlight clients without the developer having to manually poll servers for changes.  This programming model is very useful in a variety of scenarios, including instant messenger/chat applications, and monitoring/update applications like stock tickers and trader applications.

    Web Services

    Beta2 enables significantly improved interop with SOAP based web-services.  Web service proxy class end-point URLs can now be configured without recompiling applications.  Visual Studio also now has a new "Silverlight-enabled WCF Service" project item template that you can add to ASP.NET web projects to publish services to clients.

    REST and ADO.NET Data Services

    Silverlight includes support for working with REST based web-services. 

    Beta2 adds support for calling and consuming ADO.NET Data Services (formerly code-named: "Astoria").  ADO.NET Data Services will ship as part of .NET 3.5 SP1 and makes it easy to publish data end-points within an ASP.NET web project that are consumable from any client using REST URIs.  Silverlight Beta2 now includes ADO.NET Data Service client support that allows you to easily call these services (and optionally use LINQ expressions within Silverlight to express remote REST queries to them).

    JSON

    Silverlight supports calling JSON-based services on the web. 

    Beta2 now includes LINQ to JSON support that enables you to easily query, filter, and map JSON results to .NET objects within a Silverlight application.  This makes it easy to call and work with existing AJAX end-points and services published on the web. 

    Data Improvements

    Silverlight 2 Beta2 includes a bunch of work in the data space:

    DataGrid

    Beta2 adds a number of new features to the DataGrid control. These include:

    • Auto-sizing support for columns and rows
    • Column sorting (with both single column and multi-column sort support) 
    • Column re-ordering support by end-users (allowing them to drag/drop columns to re-arrange the order)
    • Frozen column support (allowing you to prevent a particular column from being customized)
    • Performance and bug fixes

    DataBinding

    Beta2 adds more core data-binding features and better validation support.  These include:

    • Per-binding Validation and BindingValidationError event handler support on controls (allowing you to handle input validation with TwoWay bindings)
    • Support for binding expressions on attached properties
    • Richer binding value conversion support (including value conversion fallback support)

    Isolated Storage

    Silverlight enables applications to store data locally on a client (via a feature we call "Isolated Storage").  Applications can prompt users to grant them size permissions for this storage (for example: a user might grant an email program 50MB of local storage). 

    Beta2 increases the default local storage space provided to Silverlight applications to 1MB in size.  Beta2 also now provides better end-user support for managing per-site storage permissions, as well as the ability to easily revoke/delete an application's local storage.  Management UI to control this can now be brought up by an end-user by right-clicking on a Silverlight application and choosing the "Silverlight Configuration" menu option.

    Understanding Compatibility with Silverlight 1.0 and Silverlight 2 Beta 1

    Silverlight 2 Beta2 is compatible with applications that target Silverlight 1.0.

    Silverlight 2 Beta2 will not run applications that target Silverlight 2 Beta1, since we've made a number of API changes between the two betas for the new features being added in Silverlight 2.  Browsers that have Silverlight 2 Beta1 installed which visit a site that hosts a Silverlight Beta2 application will be prompted to upgrade to the newer beta of Silverlight.  Once they do this they won't be able to run Beta1 applications without uninstalling Beta2.  This means that if you have published a running sample on the web built with Beta1 you will probably want to update it to Beta2 soon. 

    We have published a document that details the changes between Beta1 and Beta2 here that can help with this.  I also recommend reading Shawn Wildermuth's What Changed in Silverlight 2 Beta2 and Upgrading your Silverlight 2 Projects to Beta2 posts for more details on some of the changes between Beta1 and Beta2.

    Summary

    To learn more about Silverlight 2 and download the Beta2 release, please visit the http://www.silverlight.net and http://expression.microsoft.com web-sites.  We'll be posting articles, tutorials, videos and more on both sites in the days and weeks ahead.  I'll also be posting some tutorials of my own here on my blog as well. 

    If you haven't already read them I'd also recommend checking out my previous First Look at Silverlight 2 and First Look at Expression Blend with Silverlight 2 blog posts that I wrote a few months ago when Beta1 shipped, since they provide a good overview of the Silverlight programming model and how to target it using both Visual Studio 2008 and Expression Blend.

    Hope this helps,

    Scott

  • ASP.NET MVC Support with Visual Web Developer 2008 Express

    Last week I blogged about the ASP.NET MVC Preview 3 release.  One important thing I forgot to mention about this release is that you can now use it with both Visual Studio 2008 as well as the free Visual Web Developer 2008 Express edition. 

    The SP1 release of Visual Web Developer 2008 Express adds support for both class library projects as well as web application projects (previously only web site projects could be used with it).  This new support is useful in itself, as well as in enabling both ASP.NET MVC and Silverlight project support with VWD Express.  If you install the Visual Web Developer Express SP1 Beta you can start using ASP.NET MVC Preview 3 with it immediately.

    Important: ASP.NET MVC Preview 3 does not require SP1 to be installed if you are using Visual Studio 2008.  ASP.NET MVC Preview 3 will work with both VS 2008 and VS 2008 SP1 just fine. 

    You can learn more about the new VWD Express support for ASP.NET MVC from the VS Web Tools team blog here.  This post also includes a free web download that provides ASP.NET MVC Test project support for NUnit-based unit tests.  You can use these NUnit project templates with both Visual Studio 2008 as well as with Visual Web Developer Express 2008.

    Hope this helps,

    Scott

  • May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF

    Apologies for the sparseness of my posting the last few weeks - work and life have been busy here lately.  Below is a new post in my link-listing series to help kick things up a little.  Also check out my ASP.NET Tips, Tricks and Tutorials page and Silverlight Tutorials page for links to popular articles I've done myself in the past.

    ASP.NET

    • ASP.NET Perf Issue: Large numbers of application-restarts due to virus scanners: Tess Ferrandez has a great post that details a debug session to determine why an ASP.NET application was restarting frequently (causing performance slowdowns).  The issue was a virus scanner that was causing files to be constantly updated.  Make sure to check out the logging code you can add to your application to identify restart causes like this.

    ASP.NET AJAX

    .NET

    • 7 Ways to Simplify your code with LINQ: Igor Ostrovsky has a great blog post that talks about new code techniques you can use to improve your code using .NET 3.5 and the new language and LINQ features in it.

    • Visual LINQ Query Builder for LINQ to SQL: Mitsu Furuta has created a cool Visual Studio designer that allows you to graphically construct LINQ to SQL queries.  Also make sure to download download the latest LINQPad utility - which is invaluable for learning LINQ and trying out LINQ queries.

    • Ukadc.Diagnostics: Josh Twist pointed me at a new CodePlex project he is working on that extends the System.Diagnostics features in .NET to include richer logging features (SQL trace support, email support, etc).

    Visual Studio

    Silverlight

    • Silverlight 2 Pie Chart: Peter McGrattan has posted a nice control and article that demonstrates how to use a new Silverlight charting control he has written.

    WPF

    • WPF week on Channel9: Watch 6 great videos on Channel9.  Each one includes interviews and demos with members of the WPF team talking about some of the awesome work that went into WPF 3.5 SP1 (read my blog post here for a summary of some of it).

    • WPF Testing and Application Quality Guide: Check out the 0.2 release of a free online book being developed by Microsoft that covers how to test WPF applications.  Definitely worth book-marking if you are doing WPF development.

    • WPF 3.5 SP1 StringFormat: Lester has a nice post that describes how to use the new StringFormat feature in WPF 3.5 SP1.  This makes it much easier to handle formatting of databound values.

    Hope this helps,

    Scott

  • Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta

    Earlier today we shipped a public beta of our upcoming .NET 3.5 SP1 and VS 2008 SP1 releases.  These servicing updates provide a roll-up of bug fixes and performance improvements for issues reported since we released the products last November.  They also contain a number of feature additions and enhancements that make building .NET applications better (see below for details on some of them).

    We plan to ship the final release of both .NET 3.5 SP1 and VS 2008 SP1 this summer as free updates.  You can download and install the beta here.

    Important: SP1 Beta Installation Notes

    The SP1 beta released today is still in beta form - so you should be careful about installing it on critical machines.  There are a few important SP1 Beta installation notes to be aware of:

    1) If you are running Windows Vista you should make sure you have Vista SP1 installed before trying to install .NET 3.5 SP1 Beta.  There are some setup issues with .NET 3.5 SP1 when running on the Vista RTM release.  These issues will be fixed for the final .NET 3.5 SP1 release - until then please make sure to have Vista SP1 installed before trying to install .NET 3.5 SP1 beta.

    2) If you have installed the VS 2008 Tools for Silverlight 2 Beta1 package on your machine, you must uninstall it - as well as uninstall the KB949325 update for VS 2008 - before installing VS 2008 SP1 Beta (otherwise you will get a setup failure).  You can find more details on the exact steps to follow here (note: you must uninstall two separate things).  It is fine to have the Silverlight 2 runtime on your machine with .NET 3.5 SP1 - the component that needs to be uninstalled is the VS 2008 Tools for Silverlight 2 package.  We will release an updated VS 2008 Tools for Silverlight package in a few weeks that works with the VS 2008 SP1 beta.

    3) There is a change in behavior in the .NET 3.5 SP1 beta that causes a problem with the shipping versions of Expression Blend.  This behavior change is being reverted for the final .NET 3.5 SP1 release, at which time all versions of Blend will have no problems running.  Until then, you need to download this recently updated version of Blend 2.5 to work around this issue.

    Improvements for Web Development

    .NET 3.5 SP1 and VS 2008 SP1 contain a bunch of feature improvements targeted at web application development. 

    The VS Web Dev Tools team has more details (including specific bug fix details) on some of the VS specific work here.  Below are more details on some of the work in the web-space:

    ASP.NET Data Scaffolding Support (ASP.NET Dynamic Data)

    .NET 3.5 SP1 adds support for a rich ASP.NET data "scaffolding" framework that enables you to quickly build functional data-driven web application. With the ASP.NET Dynamic Data feature you can automatically build web UI (with full CRUD - create, read, update, delete - support) against a variety of data object models (including LINQ to SQL, LINQ to Entities, REST Services, and any other ORM or object model with a dynamic data provider).

    SP1 adds this new functionality to the existing GridView, ListView, DetailsView and FormView controls in ASP.NET, and enables smart validation and flexible data templating options.  It also delivers new smart filtering server controls, as well as adds support for automatically traversing primary-key/foreign-key relationships and displaying friendly foreign key names - all of which saves you from having to write a ton of code.

    You can learn more more about this feature from Scott Hanselman's videos and tutorials here.

    ASP.NET Routing Engine (System.Web.Routing)

    .NET 3.5 SP1 includes a flexible new URL routing engine that allows you to map incoming URLs to route handlers.  It includes support for both parsing parameters from clean URLs (for example: /Products/Browse/Beverages), as well as support to dynamically calculate and generate new URLs from route registrations.

    This new routing engine is used by both ASP.NET Dynamic Data as well as the new ASP.NET MVC framework.  It will support both WebForms and MVC based requests. 

    ASP.NET AJAX Back/Forward Button History Support

    .NET 3.5 SP1 adds new APIs to ASP.NET AJAX to allow you to better control the history list of a browser (enabling you to control the behavior of the back/forward button of the browser).

    You can learn more about this feature in the article here and the screencast here.

    ASP.NET AJAX Script Combining Support

    .NET 3.5 SP1 introduces a new <CompositeScript> element on the <asp:ScriptManager> server control, which allows you to declaratively define multiple script references within it.  All the script references within the CompositeScript element are combined together on the server and served as a single script to the client, reducing the number of requests to the server and improving page load time for ASP.NET AJAX applications.

    The script combining feature supports both path based scripts and assembly resource based scripts, and dynamically serves up the combined scripts using the ScriptResources.axd handler.

    Visual Studio 2008 Performance Improvements HTML Designer and HTML Source Editor

    In February we released a HotFix roll-up that included a number of performance improvements and bug fixes for the VS 2008 Web Designer.  VS 2008 SP1 includes all of these fixes, as well as a number of additional performance improvements.

    Visual Studio 2008 JavaScript Script Formatting and Code Preferences

    Visual Studio has for several releases supported rich source code formatting options for VB and C# (spacing, line breaks, brace positions, etc).

    VS 2008 SP1 adds richer source code formatting support for JavaScript as well (both inline <script> blocks and .js files).  You can now set your Javascript coding preferences using the Tools->Options dialog:

    These preferences will be automatically used as you type new Javascript code in the source editor.  You can also select existing code, right-click, and choose the "Format Selection" option to apply your style preferences to existing JavaScript code.  You can learn more about this new feature here.

    Better Visual Studio Javascript Intellisense for Multiple Javascript/AJAX Frameworks

    VS 2008 includes Javascript Intellisense support in source view.  The intellisense support with the initial VS 2008 release works well with vanilla JavaScript as well as code written using the ASP.NET AJAX JavaScript type patterns.  JavaScript is a very flexible language, though, and many JavaScript libraries use this flexibility to full advantage to implement their features - sometimes in ways that prevented the intellisense engine from providing completion support.

    VS 2008 SP1 adds much better intellisense support for popular Javascript libraries (we specifically did work to support JQuery, Prototype, Scriptaculous, ExtJS, and other popular libraries).  You will get better default intellisense when you reference these libraries.  We are also looking at whether we can maintain additional intellisense hint files that you can download to get even better intellisense and documentation support for some of the more popular libraries.

    Below is an example of using a JQuery startup function with the VS 2008 SP1 JavaScript intellisense engine:

    Notice below how VS 2008 SP1 can now provide method argument completion even on chained JQuery selectors:

    Visual Studio Refactoring Support for WCF Services in ASP.NET Projects

    VS 2008 SP1 adds better refactoring support for WCF services included within both ASP.NET Web Site and ASP.NET Web Application Projects.

    If you use the refactoring support to rename the class name, interface contract, or namespace of a WCF service, VS 2008 SP1 will now automatically fix up the web.config and SVC file references to it.

    Visual Studio Support for Classic ASP Intellisense and Debugging

    Previous versions of Visual Studio included support for intellisense and debugging within classic ASP (.asp) pages.  The file and project templates to create classic ASP pages/projects hasn't been in VS for a few releases, though, and with the initial VS 2008 we incorrectly assumed this meant that people weren't still using the classic ASP support.  We heard feedback after we shipped that indeed they were. 

    With VS 2008 SP1 this support for classic ASP intellisense and debugging is back:

     

    Visual Web Developer Express Edition support for Class Library and Web Application Projects

    The Visual Web Developer 2008 Express edition (which is free) is being updated in SP1 to add support for both class library and ASP.NET Web Application project types.  Previous versions of Visual Web Developer Express only supported ASP.NET web-site projects.

    Among other benefits, the support of class library and web application projects will enable ASP.NET MVC and Silverlight projects to be built with the free Visual Web Developer 2008 Express.  All of the above JavaScript, Dynamic Data, Classic ASP, and AJAX improvements work with Visual Web Developer Express as well.

    Improvements for Client Development

    .NET 3.5 SP1 and VS 2008 SP1 contain major performance, deployment, and feature improvements for building client applications. 

    Tim Sneath has a great blog post that talks about some of the client improvements here.  Below are more details on them:

    Application Startup and Working Set Performance Improvements

    .NET 3.5 SP1 includes significant performance improvements to the CLR that enable much faster application startup times - in particular with "cold start" scenarios (where no .NET application is already running).  Much of these gains were achieved by changing the layout of blocks within CLR NGEN images, and by significantly optimizing disk IO access patterns.  We also made some nice optimizations to our JIT code generator that allow much better inlining of methods that utilize structs.

    We are today measuring up to 40% faster application startup improvements for large .NET client applications with SP1 installed.  These optimizations also have the nice side-effect of improving ASP.NET application request per second throughput by up to 10% in some cases.

    New .NET Framework Client Profile Setup Package

    .NET 3.5 SP1 introduces a new setup package option for developers building .NET client applications called the ".NET Framework Client Profile".  This provides a new setup installer that enables a smaller, faster, and simpler installation experience for .NET client applications on machines that do not already have the .NET Framework installed.

    The .NET Framework Client Profile setup contains just those assemblies and files in the .NET Framework that are typically used for client application scenarios.  For example: it includes Windows Forms, WPF, and WCF.  It does not include ASP.NET and those libraries and components used primarily for server scenarios.  We expect this setup package to be about 26MB in size, and it can be downloaded and installed much quicker than the full .NET Framework setup package.

    The assemblies and APIs in the .NET Framework Client setup package are 100% identical to those in the full .NET Framework setup package (they are literally the same binaries).  This means that applications can target both the client profile and full profile of .NET 3.5 SP1 (no recompilation required).  All .NET applications that work using the .NET Client Profile setup automatically work with the full .NET Framework.

    A developer can indicate that the client application they are building supports both the .NET Framework Client Profile and the full .NET Framework by pulling up the project properties page for a client application within VS 2008 SP1.  Within the project properties page they can select a new checkbox that indicates it only requires those assemblies included in the .NET Framework Client Profile:

    VS 2008 will then ensure that the project can only reference those assemblies shipped in the client profile setup package (and it will generate a compile error if you try and use a type in an assembly not included in the client redist).  The compiled client application will then run on machines that have both the full .NET Framework installed, as well as machines that only have the .NET Framework Client Profile installed.

    If you have a machine that only has the .NET Framework Client Profile installed, and you try and run a .NET application on it that did not mark itself as supporting the .NET Framework Client Profile, then the CLR will refuse to run the application - and will instead prompt the end-user to upgrade to the full .NET Framework package.  This ensures that applications always run correctly - and that developers do not need to worry about missing assembly exceptions at runtime if a user tries to run an application that requires the full .NET Framework on a machine that only has the .NET Framework Client Profile installed.

    We believe that a large class of .NET client applications will be able to use this new .NET Client Profile setup to significantly speed up their installation, and enable a much more consumer friendly experience.

    New .NET Framework Setup Bootstrapper for Client Applications

    .NET 3.5 SP1 introduces a new "bootstrapper" component that you can use with client applications to help automate making sure that the right version of the .NET Framework is installed. 

    The bootstrapper component can handle automatically downloading and installing either the .NET Framework Client Profile or the full .NET Framework Setup Package from the Internet if your machine doesn't have either of them installed.  The boostrapper can also automatically handle upgrading machines that have a previous version of the .NET Framework installed.  For example, if your machine already has .NET 3.0 installed, and your application requires .NET 3.5, the bootstrapper can optionally download just the update files needed to upgrade it to .NET 3.5 (and avoid having to download the full .NET Framework setup download).

    The setup bootstrapper component can be used with both ClickOnce based setup packages, as well as with third party installer products (like Installshield).  The boostrapper optionally enables fully customized setup branding experiences (splash screens, custom setup wizard steps, etc) and should make it much easier to build optimized client setup experiences.

    ClickOnce Client Application Deployment Improvements

    .NET 3.5 SP1 includes several improvements for ClickOnce deployment of both Windows Forms and WPF applications.  Some of these improvements include:

    • Support for the .NET Framework Client Profile (all ClickOnce features are supported with it)
    • ClickOnce applications can now be programmatically installed through a ‘Setup.exe’ while displaying a customized, branded install UX
    • ClickOnce improvements for generating MSI + ClickOnce application packages
    • ClickOnce error dialog boxes now support links to application specific support sites on the Web
    • ClickOnce now has design-time support for setting up file associations
    • ClickOnce application publishers can now decide to opt out of signing and hashing the ClickOnce manifests as they see appropriate for their scenarios.
    • Enterprises can now choose to run only Clickonce Applications Authenticode signed by ‘Known Publishers’ and block anything else from running
    • FireFox browser extension to support Clickonce installations using FireFox browsers

    Windows Forms Controls

    SP1 adds several new Windows Forms controls - including new vector shape, Printing, and DataRepeater controls:

     

    WPF Performance Improvements

    .NET 3.5 SP1 includes several significant performance optimizations and improvements to WPF.  Some of the specific graphics improvements include:

    • Smoother animations
    • Hardware accelerated rendering of Blur and DropShadow Bitmap Effects
    • Text Rendering speed improvements - especially with VisualBrish and 3D scenes
    • 2D graphics improvements - especially with z-index scenarios
    • A new WriteableBitmap class that enables real-time and tear-free bitmap updates.  This enables custom "paint"-style applications, data visualizations, charts and graphs that optionally bypass the default WPF 2D graphics APIs.
    • Layered window performance improvements

    SP1 also adds support for better data scalability in WPF.  The ListView, ListBox and TreeView controls now support "item container recycling" and "virtualization" support which allows you to easily achieve a 40% performance improvement with scrolling scenarios.  These controls also now optionally support a "deferred scrolling" feature which allows you to avoid scrolling in real time and instead wait until a user releases the scroll thumb (the default scrolling mode in Outlook). This can be useful when scrolling over very large data sets quickly. 

    WPF Data Improvements

    .NET 3.5 SP1 includes several data binding and editing improvements to WPF.  These include:

    • StringFormat support within {{ Binding }} expressions to enable easy formatting of bound values
    • New alternating rows support within controls derived from ItemsControl, which makes it easier to set alternating properties on rows (for example: alternating background colors)
    • Better handling and conversion support for null values in editable controls
    • Item-level validation that applies validation rules to an entire bound item
    • MultiSelector support to handle multi-selection and bulk editing scenarios
    • IEditableCollectionView support to interface data controls to data sources and enable editing/adding/removing items in a transactional way
    • Performance improvements when binding to IEnumerable data sources

    WPF also now exposes hooks that enable developers to write custom panels w/ virtualized scrolling.  We'll be using this support together with the above data binding improvements to build the new WPF datagrid that will be shipping later this year.

    WPF Extensible Shader Effects

    .NET 3.5 SP1 adds support in WPF for a new shader effects architecture and API that allows extremely expressive visual effects to be created and applied to any control or element within WPF.  These shader effects support blending multiple input compositions together.  What makes them particularly powerful is that WPF executes effects (including custom effects you build yourself) using the GPU - giving you fully hardware accelerated graphics performance.  Like almost everything in WPF, you can also use WPF databinding and animation on the properties of an effect (allowing them to be fully integrated into an experience).

    Applying an effect onto a Control is super easy - just set a Control's "Effect" property.  For example, to add a hardware accelerated drop-shadow effect on a button you can use the built-in <DropShadowEffect> on it via either code or XAML:

    Which will cause the button to render like so:

    Because Effects are extensible, developers can create their own custom Effect objects and apply them.  For example, a custom "DirectionalBlurEffect" could be created and added to a ListBox control to change its scroll appearance to use a blur effect if you rapidly scroll across it:

    Keep an eye on Greg Schechter's blog to learn more about how the Effects architecture works and to learn how you can both create and apply new effects within your applications. 

    Note: In addition to introducing the new Shader Effects API, WPF in SP1 also has updated the existing Blur and DropShadow Bitmap effects already in WPF to be hardware accelerated.

    WPF Interoperability with Direct3D

    .NET 3.5 SP1 adds support to efficiently integrate Direct3D directly into WPF.  This gives you more direct access to the hardware and to take full advantage of the Direct3D API within WPF applications.  You will be able to treat Direct3D content just like an image within an application, as well as use Direct3D content as textures on WPF controls. 

    For example, below are three samples from the Direct3D SDK:

    We could either load them in as image surfaces within a WPF application, or map them as textures on WPF controls.  Below is an example of mapping them as textures onto cubes in a WPF 3D application:

    Note: the Direct3D integration isn't today's SP1 beta release.  It will appear in the final SP1 release.

    VS 2008 for WPF Improvements

    VS 2008 SP1 includes several significant improvements for WPF projects and the WPF designer.  These include:

    • Several performance improvements
    • Events tab support within the property browser
    • Ability to sort properties alphabetically in the property browser
    • Margin snaplines which makes form layout much quicker
    • Better designer support for TabControl, Expander, and Grid
    • Code initiated refactoring now updates your XAML (including both control declarations and event declarations in XAML)
    • Go to Definition and Find All References now support things declared in XAML

    The debugger has also been updated in SP1 so that runtime errors in XAML markup (for example: referencing styles, datasources and/or other objects that don't exist) will now be better identified within the debugger:

    Data Development Improvements

    .NET 3.5 SP1 and VS 2008 SP1 include a bunch of improvements for data development. Some of them include:

    SQL 2008 Support

    VS 2008 and .NET 3.5 are being updated to include support for the upcoming SQL 2008 release.  Visual Studio 2008 data designers, projects and wizards now fully supporting connecting and working against SQL 2008 databases. 

    ADO.NET Entity Framework and LINQ to Entities:

    .NET 3.5 SP1 includes the new ADO.NET Entity Framework, which allows developers to define a higher-level Entity Data Model over their relational data, and then program in terms of this model.  Concepts like inheritance, complex types and relationships (including M:M support) can be modeled using it.  VS 2008 SP1 now includes built-in designer support to help with this modeling:

    The ADO.NET Entity Framework and the VS 2008 Entity Framework Designer both support a pluggable provider model that allows them to be used with any database (including Oracle, DB2, MySql, PostgreSQL, SQLite, VistaDB, Informix, Sybase, and others).

    Developers can then use LINQ and LINQ to Entities to query, manipulate, and update these entity objects.

    ADO.NET Data Services (formerly code-named "Astoria")

    .NET 3.5 SP1 includes a flexible framework that enables the creation of REST-based data services.  Formerly code-named "Astoria", t