This article shows how easy it is to display images in ItemsControl element using simple DataBinding. Answer posted to these MSDN questions (1, 2) Let's take a look at this sample code for the implementation details:
<
GridView
x:Name
=
"gridView"
ItemsSource
"{Binding Items}"
>
GridView.ItemTemplate
DataTemplate
StackPanel
TextBlock
Text
"{Binding Txt}"
/>
Image
Source
"{Binding ImageUri}"
Height
"60"
Width
</
class
GridVwItem
{
public
Uri ImageUri {
get
;
set
; }
string
Txt {
}
GridVwModel
List<GridVwItem> Items {
GridVwModel()
//Dummy Data
Items =
new
List<GridVwItem>();
Items.Add(
GridVwItem() { ImageUri =
Uri(
"ms-appdata:///local/Logo.png"
), Txt=
"1"
});
"ms-appdata:///local/EnterButton.png"
), Txt =
"2"
"ms-appdata:///local/SplashScreen.png"
"3"
sealed
partial
MainPage : Page
MainPage()
this
.InitializeComponent();
.DataContext =
GridVwModel();
Naomi N edited Original. Comment: Minor edit