FileToVisualConverter
public class StringToVisualConverter : IValueConverter { #region IValueConverter 成員 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (null != value) { string str_ExePath = value.ToString(); if (!System.IO.File.Exists(str_ExePath)) return null; System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(str_ExePath); return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon( icon.Handle, new Int32Rect(0, 0, icon.Width, icon.Height), System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); } return null; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion }