private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListView imageList = (ListView)sender; DreamingModel dreaming = (imageList.DataContext) as DreamingModel; Frame.Navigate(typeof(ImageView), dreaming); }
//评论 private void comment_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; DreamingModel dreaming = (btn.DataContext) as DreamingModel; Frame.Navigate(typeof(DreamingComment), dreaming); }
//点赞 private void praise_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; DreamingModel dreaming = (btn.DataContext) as DreamingModel; HtppPostPraise.HttpPost(dreaming._id, dreaming.user_phone, Config.UserPhone, Config.UserImage, Config.UserName); btn.Content = ((int)btn.Content + 1).ToString(); btn.IsEnabled = false; }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { dreaming = (DreamingModel)e.Parameter; this.flipview.ItemsSource = dreaming.image; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null && e.Parameter is DreamingModel) { dreaming = (DreamingModel)e.Parameter; postGrid.DataContext = dreaming; LoadComment(dreaming._id); } else if (e.Parameter != null && e.Parameter is UserModel) { UserModel user = e.Parameter as UserModel; LoadPost(user.day); LoadComment(user.day); } }
async void LoadPost(string id) { string response = await HttpGet.HttpGets(Config.apiDreamingOne + id); if (response != null) { try { DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(DreamingModel)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response)); dreaming = ds.ReadObject(ms) as DreamingModel; postGrid.DataContext = dreaming; } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } } }