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:
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); 