using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ImageList.Model { public class ImageDetails { /// <summary> /// A name for the image, not the file name. /// </summary> public string Name { get; set; } /// <summary> /// A description for the image. /// </summary> public string Description { get; set; } /// <summary> /// Full path such as c:\path\to\image.png /// </summary> public string Path { get; set; } /// <summary> /// The image file name such as image.png /// </summary> public string FileName { get; set; } /// <summary> /// The file name extension: bmp, gif, jpg, png, tiff, etc... /// </summary> public string Extension { get; set; } /// <summary> /// The image height /// </summary> public int Height { get; set; } /// <summary> /// The image width. /// </summary> public int Width { get; set; } /// <summary> /// The file size of the image. /// </summary> public long Size { get; set; } } } ---------------------------------------------------------------------------------------- XAML CODE <window x:class="ImageList.MainWindow" xmlns:x="#unknown"> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded_1"> <grid> <itemscontrol name="ImageList" itemssource="{Binding ImageList}"> <itemscontrol.itemtemplate> <datatemplate> <border borderthickness="1" borderbrush="#FFD0D1D7" padding="5" margin="10,10,0,0"> <stackpanel orientation="Horizontal"> <!--image and dimensions--> <grid width="88" height="55"> <Image Source="{Binding Path}"/> <textblock removed="#B2000000" foreground="White" height="16" textalignment="Center" verticalalignment="Bottom"> <textblock.text> <multibinding stringformat="{}{0}x{1}"> <binding path="Height" /> <binding path="Width" /> </multibinding> </textblock.text> </textblock> </grid> <!--name, type and size--> <stackpanel orientation="Vertical" margin="5,0,0,0" verticalalignment="Center"> <textblock name="ImageName" margin="1" foreground="#FF787878" text="{Binding FileName}" /> <textblock name="ImageType" margin="1" foreground="#FF787878"> <textblock.text> <multibinding stringformat="Type: {0}"> <binding path="Extension" /> </multibinding> </textblock.text> </textblock> <textblock name="ImageSize" margin="1" foreground="#FF787878"> <textblock.text> <multibinding stringformat="Size: {0} Bytes"> <binding path="Size" /> </multibinding> </textblock.text> </textblock> </stackpanel> </stackpanel> </border> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </grid> </window> -------------------------------------------------------------------------------- CODE BEHIND XAML using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Drawing; using ImageList.Model; using System.IO; namespace ImageList { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded_1(object sender, RoutedEventArgs e) { string root = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string[] supportedExtensions = new[] {".png"}; var files = Directory.GetFiles(System.IO.Path.Combine(root, "Images"), "*.*").Where(s => supportedExtensions.Contains(System.IO.Path.GetExtension(s).ToLower())); // var files = Directory.GetFiles(System.IO.Path.Combine( C:\Users\apmaheshwar\Documents\visual studio 2012\Projects\WpfApplication59\WpfApplication59\ImagesP; List<ImageDetails> images = new List<ImageDetails>(); foreach (var file in files) { ImageDetails id = new ImageDetails() { Path = file, FileName = System.IO.Path.GetFileName(file), Extension = System.IO.Path.GetExtension(file) }; BitmapImage img = new BitmapImage(); img.BeginInit(); img.CacheOption = BitmapCacheOption.OnLoad; img.UriSource = new Uri(file, UriKind.Absolute); img.EndInit(); id.Width = img.PixelWidth; id.Height = img.PixelHeight; FileInfo fi = new FileInfo(file); id.Size = fi.Length; images.Add(id); } ImageList.ItemsSource = images; } private object GetExtension(string s) { throw new NotImplementedException(); } } } --------------------------------------------------------------- Can anyone please help me, I have the submission tomorrow...Please
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)