Como definir ItemsPanelTemplate para uma grade criada dinamicamente no código atrás de

Eu tenho esseUserControl definido emXAML e gostaria de definir oItemsPanelTemplate dinamicamente no meu código por trás da classe (não noXAML como no exemplo):

<UserControl>
    <ItemsControl x:Name="Items">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Grid> <!-- I want to add this Grid definition in code behind -->
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                </Grid>
            </ItemsPanelTemplate>
       </ItemsControl.ItemsPanel>
    </ItemsControl>
</UserControl>

Eu tentei algo como

this.Items.ItemsPanel.Template = new Grid();

mas falhou miseravelmente. Qualquer ajuda

Fundou sei apenas o número de colunas e linhas da grade em tempo de execuçã

questionAnswers(3)

yourAnswerToTheQuestion