Am stuck to load images from my file location in WPF.
here is my xaml
<Image Grid.ColumnSpan="3" Grid.Row="11" Height="14" HorizontalAlignment="Left" Margin="57,1,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="108" />
Here is my code behind
internal int FindImages(string slugName, DirectoryInfo outputFolder)
{
if (slugName != null)
{
List<string> filePathList = Directory.GetFiles(outputFolder.FullName).ToList();
List<string> filePathList_ToBeDeleted = new List<string>();
foreach (string filePath in filePathList)
{
if (Path.GetFileNameWithoutExtension(filePath).ToLower().Contains("_70x70"))
{
image1.Source = filePath;
}
}
int count = 0;
return count;
}
My file path shows like "\\\\Server1\\Dev\\Online\\Images\\7PMa_Test3_0306_70x70.jpg"
Set your Image source like this: <Image Source={Binding {x:Static UI:Resources. Search}} /> where 'Search' is name of the resource. Save this answer.
Here's the catch
image1.Source = new BitmapImage(new Uri(filePath));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With