ARTICLE

Adding Images to a FlipView Dynamically

Posted by Ibrahim Ersoy Articles | Windows Store Apps November 18, 2012
I was looking for a way to load images in a FlipView control dynamically and here's my solution.
Reader Level:

Hi everyone,

I was looking for a way to load images in a FlipView control dynamically and here's my solution.

We'll be creating 3 FlipViewItems and setting their Background property to 3 ImageBrush objects.

Note that, first you need to have a FlipView on your page.

Ok, let's start coding!

  1. First create 3 ImageBrush objects:

    FlipView flip1 =newFlipView();
    ImageBrush brush1 = newImageBrush();
    brush1.ImageSource =
    new BitmapImage(new Uri("ms-appx:///Assets/image1.png"));
    ImageBrush brush2 = newImageBrush();
    brush2.ImageSource =
    new BitmapImage(new Uri("ms-appx:///Assets/image2.png"));
    ImageBrush brush3 = newImageBrush();
    brush3.ImageSource =
    new BitmapImage(new Uri("ms-appx:///Assets/image3.png"));
     
  2. Then create 3 FlipViewItem objects and assign their Background property as the ImageBrush objects that we recently created:

    FlipViewItem flipvw1 = newFlipViewItem();
    flipvw1.Background = brush1;
    FlipViewItem flipvw2 = newFlipViewItem();
    flipvw2.Background = brush2;
    FlipViewItem flipvw3 = newFlipViewItem();
    flipvw3.Background = brush3;
     
  3. And finally add these FlipViewItems to a FlipView object:

    flip1.Items.Add(flipvw1);
    flip1.Items.Add(flipvw2);
    flip1.Items.Add(flipvw3);

And run it! You'll be displaying 3 images in a Flipview control now.

ss1.png

Hope it helps!

Login to add your contents and source code to this article
post comment
     

super

Posted by Vithal Wadje Nov 19, 2012
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts