Skip to content

Instantly share code, notes, and snippets.

@Tapanila
Created February 8, 2014 21:41
Show Gist options
  • Select an option

  • Save Tapanila/8890763 to your computer and use it in GitHub Desktop.

Select an option

Save Tapanila/8890763 to your computer and use it in GitHub Desktop.
using System.Windows;
using Caliburn.Micro;
using System.Collections.Generic;
namespace TT_WP8_Caliburn_2.ViewModels {
public class MainPageViewModel : Screen
{
private string _information;
public string Information
{
get
{
return _information;
}
set
{
//We expect the setter only pass the number of items
//So we add the Prefix on setting the value
_information = "Items: " + value;
NotifyOfPropertyChange(() => Information);
}
}
private List<int> _items;
public List<int> Items
{
get
{
return _items;
}
set
{
_items = value;
NotifyOfPropertyChange(() => Items);
}
}
public MainPageViewModel()
{
//Populate the list with 4 values on start
Items = new List<int>{1,2,3,4};
//Update Information text
Information = Items.Count.ToString();
}
//Called on button press
public void FetchList()
{
//Update list of Items
Items = new List<int>{0,1,2,3,4,5,6,7,8,9};
//Update Information text
Information = Items.Count.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment