|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace CarSelector
{
public partial class ListPage : UserControl
{
public ListPage()
{
InitializeComponent();
(Application.Current as App).Service.GetCarsOverviewCompleted += new EventHandler<CarSelector.CarService.GetCarsOverviewCompletedEventArgs>(service_GetCarsOverviewCompleted);
(Application.Current as App).Service.UpdateCarCompleted += new EventHandler<CarSelector.CarService.UpdateCarCompletedEventArgs>(Service_UpdateCarCompleted);
// fetch cars
DoRefresh();
}
void service_GetCarsOverviewCompleted(object sender, CarSelector.CarService.GetCarsOverviewCompletedEventArgs e)
{
carsDataGrid.Focus(); // SL2 bug
carsDataGrid.ItemsSource = e.Result;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
int id = (int)(sender as Button).Tag;
(Application.Current as App).NavigateToDetail(id);
}
void Service_UpdateCarCompleted(object sender, CarSelector.CarService.UpdateCarCompletedEventArgs e)
{
if (e.Result)
{
// car was updated: force refresh
DoRefresh();
}
}
protected void DoRefresh()
{
(Application.Current as App).Service.GetCarsOverviewAsync();
}
}
}
|
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.
I'm working since 1999 in an IT environment: started developing in PROGRESS 4GL, then VB6 and am working since 2003 with C#. I'm currently transitioning to HTML5, CSS3 and JavaScript for the front-end development.
I started my own company (TRI-S) in 2007 and co-founded another one (Cogenius) in 2012.
Besides being a Microsoft Certified Professional Developer (MCPD) I'm also a Microsoft Certified Trainer (MCT) and am teaching .NET and JavaScript courses.