WPF - Drag & Drop file extract icon and convert to bitmap (show on button or other object)
I'm working with WPF, and trying to implement a form to receive a Drag and Drop link, and assign to a button on a record (attach links to files to a record).
I can get the link path with no issue. I'm stuck trying to extract the icon file from the link, and convert and render it.
private void frmMain_Drop(object sender, DragEventArgs e)
{
String[] sFileList = (String[])e.Data.Ge开发者_StackOverflowtData(DataFormats.FileDrop);
foreach (String sFilename in sFileList)
{
String sNew = sFilename;
}
}
That is what I have so far.
Thanks!
Would this work for you?
myImageControl.Source = new BitmapImage(new Uri(sFilename));
Where myImageControl
is an Image
declared somewhere in your application's XAML:
<Image x:Name="myImageControl" />
精彩评论