I am new in universal app developpment,I have a flipview with 4 buttons in each page,each button has an image(8 images in total),I have created a model class that contains the list of images and their URls:
public class SampleItem
{
public string Image1 { get; set; }
public string Image2 { get; set; }
public string Image3 { get; set; }
public string Image4 { get; set; }
public string Image5 { get; set; }
public string Image6 { get; set; }
public string Image7 { get; set; }
public string Image8 { get; set; }
}
public class ButtonImages
{
public List<SampleItem> SampleItems { get; set; }
public ButtonImages()
{
SampleItems = new List<SampleItem>();
SampleItems.Add(new SampleItem()
{
Image1 = "images/1.png"
});
SampleItems.Add(new SampleItem()
{
Image2 = "images/2.png"
});
SampleItems.Add(new SampleItem()
{
Image3 = "images/3.png"
});
...........//all the 8 images URIs
then I define my flipview named flipview1:
<Page.Resources>
<DataTemplate x:Key="FlipViewItemTemplate">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.Row="0" >
<Image Source="{Binding Image1}"/>
</Button>
<Button Grid.Column="1" Grid.Row="0">
<Image Source="{Binding Image2}" />
</Button>
<Button Grid.Column="0" Grid.Row="1">
<Image Source="{Binding Image3}"/>
</Button>
<Button Grid.Column="1" Grid.Row="1">
<Image Source="{Binding Image4}"/>
</Button>
</Grid>
</DataTemplate>
</Page.Resources>
<FlipView x:Name="flipView1" ItemTemplate="{StaticResource FlipViewItemTemplate}"/>
and this is my try to get the 8 images and put them in each 4 buttons,in each page:
private void getimages()
{
List<ButtonImages> T = new List<ButtonImages>();
ButtonImages a;
if(true)
{
a = new ButtonImages();
T.Add(a);
}
flipView1.ItemsSource = T;
}
but I get 8 pages,each page has 4 buttons,in each page one button has an image an the others are empty :(
I have debug the code,and I get all images in T as a list have you please any idea how can I correct the code
thanks for help