I am trying to create a simple Panorama application, which is really similar to the default code when you choose to create a Panorama application in Visual Studio.
What I want is, I define my own ItemViewModel
with an extra icon image field, so the new model has 4 properties: Icon
, LineOne
, LineTwo
and LineThree
. Icon
is an image or an string of path of the image file, LineOne
, LineTwo
and LineThree
are string type.
The default code has something like:
this.Items.Add(new ItemViewModel() {
LineOne = "runtime one",
LineTwo = "Maecenas praesent accumsan bibendum",
LineThree = "Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu"
});
In the LoadData
method of MainViewModel.cs
class, I am wondering if I can have something like that, but I can specify which icon image I want to set in this method? e.g.:
this.Items.Add(new NewItemViewModel() { Icon = new Image().Source == "/Images/lineone.jpg" , LineOne = "lineone", LineTwo = "linetwo", LineThree = "linethree" });
Thank you.
Make your
Icon
property asstring
and bind it toSource
ofImage
control in xamlThat you can setup your image like that (don't forget to set type of image as
Content
)