protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (this.State != null && this.State.ContainsKey("PictureViewModelData"))
{
_pictureData = this.State["PictureViewModelData"] as string;
if (_pictureData != null)
{
var deserializedObject = JsonConvert.DeserializeObject<Tuple<string, IEnumerable<Tuple<string, string>>, string>>(_pictureData);
if (deserializedObject != null)
{
_pictureViewModel = new LinkedPictureViewModel
{
LinkTitle = deserializedObject.Item1.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace(""", "\"").Replace("'", "'").Trim(),
LinkId = deserializedObject.Item3,
Pictures = deserializedObject.Item2.Select(tpl => new LinkedPictureViewModel.LinkedPicture
{
Title = tpl.Item1.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace(""", "\"").Replace("'", "'").Trim(),
ImageSource = tpl.Item2, Url = tpl.Item2
})
};
}
}
}
else if (this.NavigationContext.QueryString["data"] != null)
{
var unescapedData = HttpUtility.UrlDecode(this.NavigationContext.QueryString["data"]);
var deserializedObject = JsonConvert.DeserializeObject<Tuple<string, IEnumerable<Tuple<string, string>>, string>>(unescapedData);
if (deserializedObject != null)
{
_pictureViewModel = new LinkedPictureViewModel
{
LinkTitle = deserializedObject.Item1.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace(""", "\"").Replace("'", "'").Trim(),
LinkId = deserializedObject.Item3,
Pictures = deserializedObject.Item2.Select(tpl => new LinkedPictureViewModel.LinkedPicture
{
Title = tpl.Item1.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace(""", "\"").Replace("'", "'").Trim(),
ImageSource = tpl.Item2, Url = tpl.Item2
})
};
_pictureData = unescapedData;
}
}
if (DataContext == null || e == null)
{
DataContext = _pictureViewModel;
}
_viewModelContextService.PushViewModelContext(DataContext as ViewModelBase);
_smartOfflineService.NavigatedToView(typeof(LinkedPictureView), e == null ? true : e.NavigationMode == NavigationMode.New);
}