WPF UserControl with multiple children

I have a UserControl that I would like to have more than one child. It already has a StackPanel as it is a child, so what am I doing wrong?

Ultimately, I would like the control to automatically include some of its own children, and then, when used, allows more children to be placed inside one of its elements. I tried MSDN How to redefine a logical tree without success.

Thanks in advance.

LayerPanelItem.xaml:

<UserControl x:Class="Controls.LayerPanelItem"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 <StackPanel></StackPanel>
</UserControl>

Main.xaml:

<controls:LayerPanelItem>   
    <TextBlock>Test</TextBlock>
    <TextBlock>Test</TextBlock> <!-- Error:  The property 'Content' is set more than once. -->
</controls:LayerPanelItem>
+3
source share
2 answers

() UserControl. ItemsControl .

+2

Grid UserControl .

0

Source: https://habr.com/ru/post/1733092/


All Articles