Exemple #1
0
        /// <summary>
        /// Handles changes to the ImagePath property.
        /// </summary>
        /// <param name="d">ImageIcon</param>
        /// <param name="e">DependencyProperty changed event arguments</param>
        private static void OnImagePathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ImageIcon icon         = (ImageIcon)d;
            string    oldImagePath = (string)e.OldValue;
            string    newImagePath = icon.ImagePath;

            icon.OnImagePathChanged(oldImagePath, newImagePath);
        }
 public void openImg()
 {
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/1.jpg"
     };
     source1.Add(imgIcon);
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/2.jpg"
     };
     source1.Add(imgIcon);
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/3.jpg"
     };
     source1.Add(imgIcon);
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/4.jpg"
     };
     source1.Add(imgIcon);
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/5.jpg"
     };
     source1.Add(imgIcon);
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/6.jpg"
     };
     source1.Add(imgIcon);
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/7.jpg"
     };
     source1.Add(imgIcon);
     imgIcon = new ImageIcon()
     {
         Width = 200, Height = 200, ImagePath = "/Images/Icons/8.jpg"
     };
     source1.Add(imgIcon);
     fluidWrapPanel.ItemsSource = source1;
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();
     openFile.Filter      = "图像文件|*.png;*.jpg";
     openFile.Multiselect = true;
     if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         String[] names = openFile.FileNames;
         foreach (var item in names)
         {
             imgIcon = new ImageIcon()
             {
                 Width     = 200,
                 Height    = 200,
                 ImagePath = item
             };
             source1.Add(imgIcon);
         }
         fluidWrapPanel.ItemsSource = null;
         fluidWrapPanel.ItemsSource = source1;
     }
 }