ListView with images in Windows Phone 8.1
I am new to WP8.
I have an application.
It makes a web API call.
I am getting a list of items.
I want to display this list of items to the user with the icon to the left of it.
I guess I should be using a ListView control.
I've spent quite some time trying to find a simple example of this, but I can't.
So either:
- I'm an idiot.
- Someone will send me a link on how to do this.
- Someone will post a simple example
- I need to buy a good WP8 book (but I will have to wait a few days for delivery).
I hope someone answers 3. And I'll keep an eye on 4. And yes, I'm sure I am 1.
UPDATE:
This is my markup:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox Name="lstPremises"
ItemsSource="{Binding Items}" FontFamily="{StaticResource PivotHeaderItemFontFamily}"
Background="{StaticResource AppBarItemBackgroundThemeBrush}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Margin="12" Height="50" Width="50" Source="Images/Number-5-icon.png" ></Image>
<TextBlock Grid.Column="1" FontSize="36" Text="{Binding Caption}" TextWrapping="Wrap" FontFamily="Global User Interface"></TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
And this is my code:
public class Item
{
public string Caption;
}
public sealed partial class Management : Page
{
public Management()
{
this.InitializeComponent();
List<Item> test = new List<Item>();
Item item = new Informed.Item();
item.Caption = "Test One";
test.Add(item);
Item item2 = new Informed.Item();
item2.Caption = "Test Two";
test.Add(item2);
lstPremises.ItemsSource = test;
}
}
and this is a screenshot:
source to share
you can get a working example from here http://visualstudiomagazine.com/articles/2014/07/01/gridview-and-listview-controls.aspx or this link too these both worked for me http://channel9.msdn.com/ Series / Building-Apps-for-Windows-Phone-8-1 / 04 The second option is the video tutorial you probably get it in
source to share