Back to Devexpress

Import Type/All Types (XAML)

coderushforroslyn-116322-coding-assistance-code-providers-import-type-all-types-xaml.md

latest1.3 KB
Original Source

Import Type/All Types (XAML)

  • Aug 03, 2020

Purpose

This Code Provider is used to automatically add missing namespace declarations to XAML code. This speeds up the development process.

Availability

Available when the caret is on a type reference that can’t be resolved in the current context.

Usage

  1. Place the caret on a type reference.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu

  3. Select Import Type from the menu.

After execution, the Code Provider adds the required namespace declaration for the selected type.

xaml
<Window x:Class="DemoApplication.DemoWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        Title="DemoWindow" Height="350" Width="525">
    <dxe:ButtonEdit/>
</Window>

Note

You can also declare all namespace references used in the XAML file at once. The Code Provider used for it is called Import All Types and is available anywhere in the XAML document containing unresolved types.

See Also

Referencing Namespaces