public static void VisualizeAllElementsToPanel <T>(Panel panel, IList <T> itemsInfo) where T : IDescription { var baseDirectory = App.FileManager.GetBaseDirectory(typeof(T).Name); panel.Children.Clear(); for (int k = 0; k < 1; k++) { for (int i = 0; i < itemsInfo.Count; i++) { var nestedPanel = new StackPanel(); nestedPanel.Margin = new Thickness(10, 0, 0, 20); nestedPanel.Height = 200; nestedPanel.Width = 200; var image = new Image(); image.Height = 180; image.MaxHeight = 180; image.Width = 180; image.MaxWidth = 180; image.Stretch = System.Windows.Media.Stretch.UniformToFill; // Loading an image LoadImage(baseDirectory, itemsInfo[i].Name, image); // Add image to Stack Panel nestedPanel.Children.Add(image); // Loading other components as Name, Genre, Year etc. PushItemsInPanel(nestedPanel, itemsInfo[i]); // Set event args var eventInfo = itemsInfo[i]; // Set Mouse Click event to Image nestedPanel.MouseLeftButtonDown += (sender, args) => { var catalogItemInfo = new InformationAboutCatalogItem(eventInfo, baseDirectory); catalogItemInfo.ShowDialog(); }; panel.Children.Add(nestedPanel); } } }
public InformationAboutCatalogItem() { this.InitializeComponent(); Instance = this; }