Deborah's Developer MindScape






         Tips and Techniques for Web and .NET developers.

October 31, 2013

XAML: Intellisense for Resources

Filed under: C#,VB.NET,Visual Studio,XAML @ 10:30 am

Visual Studio 2013 now provides Intellisense for your XAML resources.

If you code your XAML directly using the Code Editor you’ve seen the XAML Intellisense. Sure, it helps by giving you the list of element tags and the valid attributes of the type.  But in prior versions of Visual Studio, Intellisense was lacking in a few key areas. For example, it did not help you find your resources.

One of the really great things about XAML-based applications is the flexibility and control in defining styles for the displayed elements. But as we add more styles, it gets harder and harder to keep track of all of the style resources.

Even in a small application it’s hard to remember which styles have been defined. The user wants the column headers to be left-justified. Did we already create a style for that?

In prior versions of Visual Studio, we would have to start searching through our style resources to see if we have a left-justified header style.

Not any more!

The Static Resource mark-up extension now provides Intellisense!

  • Move the cursor into the Static Resource extension anywhere after the StaticResource keyword.
  • Press Ctrl + Space

image

Sweet!

  • Arrow down to the desired style.
  • Press Enter or Tab to select it.

And the Intellisense is smart! The drop down list only contains styles appropriate for a TextBlock element.

image

Using Intellisense on a Border element displays this:

image

The drop down list does not include any of the TextBlock styles, only the styles defined for a Border element.

Intellisense also understands scope. It will combine resources appropriate for the current scope including resources defined in the page and resources defined in resource dictionaries.

The Intellisense available with the StaticResource mark-up extension helps you locate and select the styles you need when you need them.

And it works for more than styles. If you have any other resources defined in your application, such as references to your converters, those also support Intellisense.

Enjoy!

For more information on the many new Visual Studio 2013 features, check out my new Pluralsight course: Mastering Visual Studio 2013.

RSS feed for comments on this post. TrackBack URI

Leave a comment

© 2020 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs