Hello i want to change an image by opening en openfiledialog and selecting a new one.. This By changing the source.. But it doens't work.. Could you please help me? Paginaholder is my image..
private void pdfOpenen()
{
Microsoft.Win32.OpenFileDialog d = new Microsoft.Win32.OpenFileDialog();
d.FileName = "Document";//begin map
Nullable<bool> pad = d.ShowDialog();
//Controleren of er een bestand geselecteerd werd
if (pad == true)
{
PaginaHolder.Source = BitmapFromUri(new Uri(pad, UriKind.Relative));
}
}
public static ImageSource BitmapFromUri(Uri source)
{
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;
}