Import Type/All Types (XAML)
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
Place the caret on a type reference.
Note
The blinking cursor shows the caret’s position at which the Code Provider is available.
<Window x:Class="DemoApplication.DemoWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="DemoWindow" Height="350" Width="525">│<dxe:ButtonEdit/> </Window>
Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu
- Select Import Type from the menu.
After execution, the Code Provider adds the required namespace declaration for the selected type.
<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