I am trying to create a ListBox in which the first item will be a separate button with my team, and after it all the other items from the ItemsSource with a general design will go. It should look something like this. 
This is a ListBox
<ListBox Margin="0,87,0,0" ItemsSource="{Binding Divisions}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectedItem="{Binding SelectedDivision}"> <TextBlock Width="200" Height="50" Margin="0" Padding="0" Text="Add" /> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Margin" Value="5" /> <Setter Property="BorderBrush" Value="Black" /> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Width="90" Orientation="Vertical"> <TextBlock Width="200" Height="50" Margin="0" Padding="0" Text="{Binding Name}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> But with this implementation, it produces:
An unhandled exception of the type "System.InvalidOperationException" in PresentationFramework.dll Additional Information: The Items family must be empty before using the ItemsSource property.
But how to implement a different idea I have not.
TextBlockto theListBox, which means adding a new Item to its collection, and then you try to set anItemsSourceand then you have a conflict, becauseListBoxnot empty, but you need to do the binding. So theTextBlockclearly superfluous here.как реализовать по другому- for example . That is, makeUserControlwith the desired design, create a ViewModel for them, well, associate everything with an associated collection. - EvgeniyZ<TextBlock ... Text="Add" />to the top of theDivisionscollection - Alias