#293 – Intellisense Will Show Overloaded Methods

Intellisense in Visual Studio presents you with a list of possible methods that you can call, based on what you’ve already typed.  If there are overloaded methods available in the current context, it will let you cycle through a list of the methods.  Overloaded methods are methods that have the same name, but a different argument list and/or return type.

In the example below, there are three different methods named Bark in the Dog class.  After you’ve entered the full method name and the opening parenthesis, Intellisense displays information about the first of the three methods.  The first overload of Bark takes a single int parameter.

If you press the down arrow key, or click on the downward facing arrow icon, Intellisense shows you the second of the three methods.

You can press the down arrow key again to see the third overload.

#292 – Intellisense Includes Information About a Method’s Parameters

Intellisense will display not only a list of methods that match what you’ve already typed, but will also show you information about the method’s parameters.

Assume that you begin entering the name of a method in the Dog class.  Intellisense shows you information about the  method.

If you now press the Tab key, Visual Studio will fill in the complete method name.

If you now enter an opening parenthesis, Intellisense will list the name of the Bark method again, with the first parameter in bold and a description of the first parameter.  (The method and parameter information will only be displayed if the class has defined the appropriate XML Documentation elements).

At this point, you can enter a value for the first parameter and then enter a comma.  Intellisense displays information about the second parameter.

#291 – Intellisense Lists Available Methods and Properties

When you type a period (.) after a variable that is a reference-typed variable, Intellisense in Visual Studio will display a list of relevant class members.

In the example below, the variable d is an instance of the Dog class.  When you enter a period (.) after the variable name, Intellisense displays a list of the members of the Dog class.  This includes both methods and properties.

You can use the arrow keys to select a specific class member.  As each class member is highlighted, information about the method or property is display to the right.

#290 – Using Intellisense in Visual Studio

Intellisense in Visual Studio is a feature that provides a list of suggested code elements that you might want to enter next, based on what you’ve already typed.

As you start typing, Intellisense will suggest  both language elements and types that match what you’ve already entered.

In the example below, I’ve entered the letter ‘w’ and Intellisense suggests some possible elements that begin with ‘w’ that I might want to enter.

If I’m actually entering a while statement, I can use the down arrow key to highlight while in the list and then press TAB.  Intellisense fills in the rest of the while keyword for me.

If I press TAB a second time, Visual Studio will actually generate a code snippet that is a template for the entire while statement.

Also notice that when Intellisense suggests a class name, it provides general information about the class.

#288 – Editing WPF Code-Behind in Visual Studio

WPF applications are made up of markup (XAML) and code-behind (managed code).  The markup defines the layout and appearance of the application, whereas the code-behind defines the behavior.

You use the code editor in Visual Studio to edit code-behind.

You can open the code editor in several different ways.

Double-click the code file from the Solution Explorer.  For C#, this is a .cs file.

Right-click a .xaml file and select View Code.

Right-click anywhere in the design view editor and select View Code.  You can do this either on the design surface or in the XAML editor.

You can also press the F7 key while you have a .xaml file open in the design view editor, or have a .xaml file selected in the Solution Explorer, to open the corresponding code-behind file in the code editor.

#286 – Adding Controls to a Window in Visual Studio by Editing XAML

You can add a WPF control to a window by using the design view editor in Visual Studio.  You add the control by dragging and dropping it onto a design surface.

You can also add a control by editing the XAML directly while in the design view editor in Visual Studio.

To open the design view editor for a particular window, double-click the associated .xaml file in the Solution Explorer.

The editor will show up as a split screen, with the design surface on the top and the XAML that defines the window contents below.

You can add a control by manually entering XAML in the lower window.  Here’s the XAML for a simple button.

As you enter XAML in the lower half of the editor, the design surface in the top half of the window will update to reflect the changes to the XAML.

#193 – You Can Have a Project Open in Blend and Visual Studio at the Same Time

Visual Studio is better for some things than Blend (e.g. writing code) and Blend is better than Visual Studio at other things (e.g. changing layout).

This means that you may often switch back and forth between the tools.  However, instead of closing and reopening the project every time, you can have the project open in both tools at the same time.

This is typically not a problem, since you’re likely not changing the same file in both tools.

If you do happen to have the same file open in both tools and you make changes and then save your changes in one tool, the other tool will warn you that changes were detected.

Visual Studio detecting changes to a file:

Blend detecting changes to a file:

The tools will warn of changes only if you happen to have the same file open in both tools.