I have a TechnicalCard class, there is a TechnicalInfoPage page for I / O of instances of a class (you can pass this instance in the constructor). There is a Window on which some infa is displayed, including a collection of TechnicalCard + button for adding instances to the collection.

How to implement it? Here is about sketched this:

<StackPanel Orientation="Horizontal"> <ItemsControl Name="icTechnicalCards"> <ItemsControl.ItemTemplate> <DataTemplate> <Frame Content="{Binding}" Margin="5"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> <Button Name="btAddTechnicalCard" Content="+" Padding="5" FontSize="28" FontWeight="Black" Background="Transparent" Click="btAddTechnicalCard_Click"/> </StackPanel> 

In the code:

 window.icTechnicalCards.ItemsSource = order.TechnicalCards.ToList().ConvertAll(x => new TechnicalInfoPage(x)); 

But then you try window.ShowDialog(); the exception "Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΡΠΊΠΈΠΌ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠΌ для страницы Page ΠΌΠΎΠΆΠ΅Ρ‚ Π±Ρ‹Ρ‚ΡŒ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Window ΠΈΠ»ΠΈ Frame" crashes, so I use Frame ... Here’s something I want to get about: Sketch Addition: What is interesting, if you place not the Page, but its contents, then everything works fine:

 icTechnicalCards.ItemsSource = order.TechnicalCards.ConvertAll(x => new TechnicalInfoPage(x).Content); 

Screenshot

    1 answer 1

    In general, the Page/Frame crutch and nothing can be done about it, in the end, Page replaced with ContentControl and everything worked as it should