Skip to main content

Remove Redundant Type Qualifier (XAML)

Purpose

Removes a redundant type qualifier when the target type is defined, for example, on a style setter. This can improve code readability.

Availability

Available when the cursor is in a redundant type qualifier.

How to Use

  1. Place the caret in a property redundant type qualifier (for example, “CheckBox.Template”).

    <Style x:Key="checkBoxStyle" TargetType="{x:Type CheckBox}">
        <Setter Property="CheckBox.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">      
                    <BulletDecorator Background="Transparent">
                        <BulletDecorator.Bullet>
                            <Grid Width="13" Height="13">
                                <Border x:Name="Border" 
                                    Background="{TemplateBinding Background}" 
                                    BorderBrush="{TemplateBinding BorderBrush}" 
                                    BorderThickness="{TemplateBinding BorderThickness}"/>
                                <Path x:Name="CheckMark" 
                                    Stroke="{DynamicResource GlyphBrush}" 
                                    StrokeThickness="2"
                                    SnapsToDevicePixels="False"
                                    Data="M 3 3 L 10 10 M 3 10 L 10 3"/>
                            </Grid>
                        </BulletDecorator.Bullet>
                    </BulletDecorator>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Remove Redundant Type Qualifier from the menu.

After execution, the Refactoring removes the redundant type qualifier.

RemoveQualifier