Q:

ItemsControl OverridesDefaultStyle

I have a Control HtNavigationMenuCategoryItem. It has set a DefaultStyleKey in it's Constructor; DefaultStyleKey = typeof(HtNavigationMenuCategoryItem);. When I do not set the Property OverridesDefaultStyle, I get the following error "itemTemplate and ItemTemplateSelector are ignored for items already of the ItemsControl's container type;". But when I override it's Style, it is not working. If i set a new Style, then everything works. Where is my mistake and how can I override the Style?
Style not working
<Style TargetType="Navigation:HtNavigationMenuCategoryItem">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Navigation:HtNavigationMenuCategoryItem">
                <Grid Margin="10,10,10,0">
                    <StackPanel Orientation="Vertical">
                        <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CategoryItems}" OverridesDefaultStyle="True">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Vertical"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Controls:FooControl Text="test" Foreground="Yellow"></Controls:FooControl>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </StackPanel>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Style working
 <Style x:Key="HtNavigationMenuCategoryItemSingle" TargetType="Navigation:HtNavigationMenuCategoryItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Navigation:HtNavigationMenuCategoryItem">
                    <Controls:FooControl Text="test" Foreground="Yellow"></Controls:FooControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

 <Style TargetType="Navigation:HtNavigationMenuCategoryItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Navigation:HtNavigationMenuCategoryItem">
                    <Grid Margin="10,10,10,0">
                        <StackPanel Orientation="Vertical">
                            <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CategoryItems}" ItemContainerStyle="{StaticResource HtNavigationMenuCategoryItemSingle}"/>
                        </StackPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Preview of the using

A:

If you want to provide a default default style for your custom WPF control you should define a static constructor that calls the DefaultStyleKeyProperty.OverrideMetadata method:
public class HtNavigationMenuCategoryItem : ItemsControl
{
    static HtNavigationMenuCategoryItem()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(HtNavigationMenuCategoryItem),
            new FrameworkPropertyMetadata(typeof(HtNavigationMenuCategoryItem)));
    }

    public List<string> CategoryItems => new List<string> { "a", "b", "c" };
}

...and define the default style in a ResourceDictionary called Generic.xaml in a folder called Themes at the root of the project in which the custom control class is defined:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Navigation="clr-namespace:WpfApplication3">

    <Style TargetType="Navigation:HtNavigationMenuCategoryItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Navigation:HtNavigationMenuCategoryItem">
                    <Grid Margin="10,10,10,0">
                        <StackPanel Orientation="Vertical" Background="Yellow">
                            <TextBlock>...</TextBlock>
                            <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CategoryItems}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Orientation="Vertical"/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                    <TextBlock Text="{Binding}" />
                                </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

This works as far as the Style and ControlTemplate are involved.

Actually I have the "Style working" solution with a second separate Style called "HtNavigationMenuCategoryItemSingle". But I want to know if it is possible or HOW I can override this Style in the ItemsControl like I was trying in the "Style not working" solution ...

I guess you could just define the ItemContainerStyle inline:
<Style TargetType="Navigation:HtNavigationMenuCategoryItem">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Navigation:HtNavigationMenuCategoryItem">
                <Grid Margin="10,10,10,0">
                    <StackPanel Orientation="Vertical">
                        <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CategoryItems}">
                            <ItemsControl.ItemContainerStyle>
                                <Style TargetType="Navigation:HtNavigationMenuCategoryItem">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="Navigation:HtNavigationMenuCategoryItem">
                                                <Controls:FooControl Text="test" Foreground="Yellow"></TextBlock>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ItemsControl.ItemContainerStyle>
                        </ItemsControl>
                    </StackPanel>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

