'WPF : Enable virtualization by default for a custom ComboBox

I made a custom ComboBox that inherits from ComboBox.

I would like enable the virtualization by default for my custom ComboBox.

I was thinking of doing it in the ComboBox constructor but I don't know if it's possible. This would allow me to avoid having to add the following code every time.

<CustomComboBox>
    <CustomComboBox.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel />
        </ItemsPanelTemplate>
    </CustomComboBox.ItemsPanel>
</CustomComboBox>

Do you have any idea how I can do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source