stackpanel with usercontrol and itemsource shows newitemplaceholder

151 Views Asked by At

Im about to create a diagram designer, and have create nodes and edges as usercontrols. I have an stackpanel where I want to place them. I have managed to make it works with the following code:

<Window.Resources>
<DataTemplate DataType="{x:Type Model:Node}">
        <Canvas>
            <View:NodeUserControl></View:NodeUserControl>
        </Canvas>
    </DataTemplate>
 </Window.Resources>

<StackPanel Name="DisplayArea">
<ItemsControl ItemsSource="{Binding Nodes}" >
</ItemsControl>
</StackPanel>

Where Nodes is an observablecollection

But this also shows an {NewItemPlaceholder} text and I can't figure out why. Would really appreciate if someone could point out my mistake.

EDIT: I have tried to create a new solution with just the beforementioned code and this doenst show the [NewItemPlaceholder}. Now Im really confused can't see the difference and what else that would cause this.

1

There are 1 best solutions below

0
On

I got the same issue and the cause was that die source data was bound twice: One time to a DataGrid control and a second bound to an ItemsControl. The ItemsControl shows its items on a canvas and also {NewItemPlaceholder} becomes visible there. The solution was to avoid adding new items to the DataGrid by: ok. I didn't need adding.