Click here to Skip to main content
15,895,746 members
Articles / Mobile Apps / Windows Phone 7

Property Finder – a Cross-Platform Xamarin MonoTouch Mobile App

Rate me:
Please Sign up or sign in to vote.
5.00/5 (17 votes)
3 Jan 2013CPOL19 min read 80.2K   1.2K   48  
A look at how Xamarin MonoTouch allows you to create cross-platform applications, using the native C# / Silverlight for Windows Phone and C#, via Xamarin MonoTouch, for iOS.
using System;
using Microsoft.Phone.Controls;
using PropertyFinder.Presenter;
using System.Windows.Navigation;
using PropertyFinder.Model;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
using System.Collections.ObjectModel;

namespace PropertyFinder
{
  public partial class SearchResultsView : PhoneApplicationPage, SearchResultsPresenter.View
  {
    private ObservableCollection<Property> _properties = new ObservableCollection<Property>();

    public SearchResultsView()
    {
      InitializeComponent();

      list.ItemsSource = _properties;
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
      base.OnNavigatedTo(e);

      if (e.NavigationMode != NavigationMode.Back)
      {
        var presenter = App.Instance.CurrentPresenter as SearchResultsPresenter;
        presenter.SetView(this);
      }
    }

    private void LoadMore_Click(object sender, RoutedEventArgs e)
    {
      LoadMoreClicked(this, EventArgs.Empty);
    }

    public void SetLoadMoreVisible(bool visible)
    {
      loadMoreButton.Visibility = visible ? Visibility.Visible : Visibility.Collapsed;
    }

    public event EventHandler LoadMoreClicked = delegate { };

    public event EventHandler<PropertyEventArgs> PropertySelected = delegate { };

    public void SetSearchResults(int totalResult, int pageNumber, int totalPages,
      List<Property> properties, string searchLocation)
    {
      _properties.Clear();
      foreach (var property in properties)
      {
        _properties.Add(property);
      }

      propertiesShown.Text = properties.Count.ToString();
      totalProperties.Text = totalResult.ToString();
      this.pageNumber.Text = pageNumber.ToString();
      this.totalPages.Text = totalPages.ToString();
    }

    public void AddSearchResults(int pageNumber, List<Property> properties)
    {
      this.pageNumber.Text = pageNumber.ToString();

      foreach (var property in properties)
      {
        _properties.Add(property);
      }
    }

    public bool IsLoading
    {
      set
      {
        loadMoreButton.IsEnabled = !value;
        loadingIndicator.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
      }
    }

    private void PropertyList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
      Property property = ((FrameworkElement)e.OriginalSource).DataContext as Property;
      if (property != null)
      {
        PropertySelected(this, new PropertyEventArgs(property));
      }
    }

  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Scott Logic
United Kingdom United Kingdom
I am CTO at ShinobiControls, a team of iOS developers who are carefully crafting iOS charts, grids and controls for making your applications awesome.

I am a Technical Architect for Visiblox which have developed the world's fastest WPF / Silverlight and WP7 charts.

I am also a Technical Evangelist at Scott Logic, a provider of bespoke financial software and consultancy for the retail and investment banking, stockbroking, asset management and hedge fund communities.

Visit my blog - Colin Eberhardt's Adventures in .NET.

Follow me on Twitter - @ColinEberhardt

-

Comments and Discussions