This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ViewModelLocator | |
{ | |
private static MyViewModel myViewModel; | |
public static MyViewModel MyViewModel | |
{ | |
get | |
{ | |
if (myViewModel == null) | |
Deployment.Current.Dispatcher.BeginInvoke(() => myViewModel = new MyViewModel()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnNavigatedTo(NavigationEventArgs e) | |
{ | |
SmartDispatcher.BeginInvoke(() => | |
{ | |
if (DataContext == null) | |
DataContext = new MainPageViewModel(); | |
// ViewModel is the DataContext typecast'd to MainViewModel | |
if (ViewModel != null && ViewModel.IsInitialized == false) | |
ViewModel.Initialize(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void PivotLayout_LoadingPivotItem(object sender, PivotItemEventArgs e) | |
{ | |
if (e.Item.Content != null) | |
return; | |
var pivot = (Pivot)sender; | |
if (e.Item == WeatherPivotItem) | |
e.Item.Content = new WeatherPivotItemControl(); | |
else if (e.Item == RegionalPivotItem) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ORIGINAL | |
private static void GetDataAsync<T, TRequest>(TRequest input, Action<T, TRequest, string> callback) | |
{ | |
var request = HttpWebRequest.Create(DBService.ServiceUrl); | |
request.Method = "POST"; | |
request.BeginGetRequestStream(asyncRequest => | |
{ | |
try |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ORIGINAL | |
public static void GetSchedules(Action<IDictionary<BaseChannel, ICollection<BaseProgram>>> callback, | |
IEnumerable<BaseChannel> channels, bool refresh = false) | |
{ | |
// Fetch the data from the online service if it's the first-load, or a force-refresh. | |
if (DBServiceCache.IsScheduleCached == false || refresh == true) | |
{ | |
lock (DBServiceCache.Schedules) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DBService.GetSchedules(channels, true) | |
.ObserveOnDispatcher() | |
.Subscribe(GetSchedulesCallback); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Date Picker --> | |
<toolkit:DatePicker ext:DatePickerExtension.Command="{Binding DateChanged}" /> | |
<!-- Time Picker --> | |
<toolkit:TimePicker ext:TimePickerExtension.Command="{Binding TimeChanged}" /> | |
<!-- List Picker --> | |
<toolkit:ListPicker DisplayMemberPath="Name" | |
ext:ListPickerExtension.Command="{Binding SelectionChanged}" | |
ItemsSource="{Binding Flowers}" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Assets | |
{ | |
using System; | |
using System.Globalization; | |
using System.Windows.Data; | |
using System.Threading; | |
public class DateTimeValueConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<phone:PhoneApplicationPage.Resources> | |
<assets:DateTimeValueConverter x:Key="DateTimeValueConverter" /> | |
<assets:ShortDatePattern x:Key="ShortDatePattern" /> | |
</phone:PhoneApplicationPage.Resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextBlock Text="{Binding Date, | |
Converter={StaticResource DateTimeValueConverter}, | |
ConverterParameter={StaticResource ShortDatePattern}}" /> |