Listing2: Page Navigation with Windows Phone and Windows 8

Loading the image with ImagePageViewModel.

public class ImagePageViewModel:INotifyPropertyChanged
{
    public Repository Repository { get; private set; }

    private FlickrImage image;
    public FlickrImage Image
    {
        get { return image; }
        set
        {
            if (Image == value) return;
            image = value;
            OnPropertyChanged("Image");
        }
    }
        
    public ImagePageViewModel(Repository repository)
    {
        Repository = repository;
    }

    public async void Load(string title)
    {
        var images = await Repository.Load();
        Image = (from img in images
                    where img.Title == title
                    select img).FirstOrDefault();
    }

    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(string propertyName)
    {
        if(PropertyChanged!=null)
              PropertyChanged(this,
                              new PropertyChangedEventArgs(propertyName));
    }
}

About the Author

Nick Randolph runs Built to Roam, a consulting company that specializes in training, mentoring and assisting other companies build mobile applications. With a heritage in rich client applications for both the desktop and a variety of mobile platforms, Nick currently presents, writes and educates on the Windows Phone platform.

comments powered by Disqus

Featured

  • Black White Wave IMage

    Neural Regression Using PyTorch: Training

    The goal of a regression problem is to predict a single numeric value, for example, predicting the annual revenue of a new restaurant based on variables such as menu prices, number of tables, location and so on.

  • Microsoft Ships Visual Studio 2019 v16.9 Servicing Baseline Release

    Microsoft is urging enterprises and professional coders to standardize on the new Visual Studio 2019 v16.9, a servicing baseline release that's guaranteed to receive official support for an extended period.

  • Microsoft Extends Low-Code Push with Power Fx Programming Language

    "Using formulas that are already familiar to hundreds of millions of users, Power Fx allows a broad range of people to bring skills they already know to low code solutions."

  • Microsoft's Tools to Fight Solorigate Attack Are Now Open Source

    Microsoft open sourced homegrown tools it used to check its systems for code related to the recent massive breach of supply chains that the company has named Solorigate.

Upcoming Events