WPF Image TemplateBinding – Programming, Pseudocode Example, C# Programming Example
WPF Form

WPF Image TemplateBinding

If we want to show an image that was saved as path into database in template, we must use covert the “image-path” to a BitmapImage object by “IValueConverter” Interface

In this tutorial, we will show step by step the all images from the database using “ListBox.ItemTemplate”

***Image doesn’t take a string as a source. So we need convert to string(path) to an ImageSource

Step 1: Creating database




Step 2: Creating a class for Images.(I named as MyImage)


Step 3: designing the WPF code


Step 4: Adding Constructor codes and Conections (Dont forget to add using System.Data.SqlClient;)


If you did all of them correct, you will show that


Step 5: Create a class that name is MyImageConverter (WPF – Image Path To )


Step 6: Use the MyImageConverter for converting path to BitmapImage


First Build Solution (F6)


Click image Source and configure


Add new Value Converter


Select MyValueConverter


Your code will change this way:







Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.