Please visit http://www.ningzhang.org!

This is a backup site. Please go to http://www.ningzhang.org for the latest content and best viewing. Thanks!

Apr 22, 2009

Add Rich Intellisense for Your Silverlight Controls

Introduction

This is part of the series on design time implementation changes in Silverlight Toolkit March 2009 Release. This post illustrates the rich intellisense support for Silverlight Toolkit, and explains implementation workflow from xmldoc in source to infotip in intellisense xml file and design assemblies.

Intellisense

Silverlight Toolkit has rich Intellisense in code and XAML editors in both Visual Studio and Blend:

  • Visual Studio Code Editor:
    VS2008 Code Editor Intellisense
  • Blend 3 Code Editor:
    Blend 3 Code Editor Intellisense
  • Blend 3 XAML editor:
    Blend 3 Xaml Editor Intellisense

Visual Studio XAML editor has intellisense too, but no infotip: Visual Studio Xaml Editor Intellisense

Implementation

Code Editor Intellisense Infotip from XML Files

The intellisense infotips in code editors in Visual Studio and Blend come from intellisense xml files installed under Silverlight SDK and Toolkit directories:

Intellisense xml files installed

Localization

Those intellisense xml files can be localized. If you install localized Visual Studio and localized Silverlight SDK, you will see localized infotips, which is a great help for those who don’t speak English. Below is the screenshot of Visual Studio running with Simplified Chinese language and simplified Chinese version of Silverlight Tools for Visual Studio SP1:

Chinese VS and Infotip

The Chinese infotip is from localized System.Windows.Controls.xml under zh-CHS sub directory:

C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client>dir/s /b system.windows.controls.xml
C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\system.windows.controls.xml
C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\zh-CHS\system.windows.controls.xml

 

XAML Editor Intellisense Infotip from Design Assemblies

The intellisense infotips in Blend 3 XAML editor come from a different mechanism: they come from DescriptionAttribute implemented by design dlls installed under the Design subdirectory:

SDK Design folder

So it is the same as infotips in Blend Properties panel (please see Design Time Features in Silverlight Toolkit for more information):

Blend Property Inspector Infotip

xmldoc comment –> intellisense xml file –> DescriptionAttribute in design assembly

All those infotips come from xml documentation comments in source code, as seen from below screenshot:

Workflow of xmldoc to infotip

  1. we put xmldoc comments in source code
  2. build generates .xml files from those xmldoc comments
  3. the generated .xml files are embedded in design dlls (see Design Time Feature Implementation in Silverlight Toolkit for more information)
  4. the control dlls, design dlls, and xml files are installed by SDK and Toolkit setup

Conclusion

This post describes the rich intellisense support of Silverlight Toolkit and its implementation workflow from xmldoc comments to intellisense xml files to design dlls. Good commenting pays!