dann_
dann_

Reputation: 47

Image Data Binding not working

Here i want to display images in dynamic list and image is taking source from data binding LineFour, Here is the Code.

 <Image Height="100" Width="100" Source="{Binding LineFour}" Margin="12,0,9,0"/>

I have this in Load Data

public void LoadData()
        {
            // Sample data; replace with real data
            this.Items.Add(new ItemViewModel() { LineOne = "beach 1", LineTwo = "hill 1", LineThree = "monu 1", LineFour="file3"});
            this.Items.Add(new ItemViewModel() { LineOne = "beach 2", LineTwo = "hill 2", LineThree = "monu 2", LineFour="file2" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 3", LineTwo = "hill 3", LineThree = "monu 3", LineFour="file3" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 4", LineTwo = "hill 4", LineThree = "monu 4", LineFour = "file2" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 5", LineTwo = "hill 5", LineThree = "monu 5", LineFour = "file3" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 6", LineTwo = "hill 6", LineThree = "monu 6", LineFour = "file2" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 7", LineTwo = "hill 7", LineThree = "monu 7", LineFour = "file3" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 8", LineTwo = "hill 8", LineThree = "monu 8", LineFour = "file2" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 9", LineTwo = "hill 9", LineThree = "monu 9", LineFour = "file3" });
            this.Items.Add(new ItemViewModel() { LineOne = "beach 10", LineTwo = "hill 10", LineThree = "monu 10", LineFour = "file2" });

            this.IsDataLoaded = true;
        }

Now the problem is images are not displaying? what to do ?

Upvotes: 0

Views: 138

Answers (1)

lopa
lopa

Reputation: 474

Go through this link

Basically providing direct url to source do not work u need to use a converter . after all Source proerty accepts an Image url but assigns a bitmap / image source object to the image control

data binding images

so basic concept is using a converter :-)

Upvotes: 1

Related Questions