Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- using Microsoft.Phone.Controls;
- namespace samples_imap
- {
- public partial class samples2 : PhoneApplicationPage
- {
- private bool isShowing = false;
- private MovieList lista;
- // Constructor
- public samples2()
- {
- InitializeComponent();
- fillListBox();
- }
- // Constructor
- public void fillListBox()
- {
- lista = new MovieList();
- this.listBoxEmail.ItemsSource = lista;
- }
- private void btnEcho_Click(object sender, RoutedEventArgs e)
- {
- }
- private void CheckBox_Checked(object sender, RoutedEventArgs e) {
- ListBoxItem checedItem = this.listBoxEmail.ItemContainerGenerator.ContainerFromItem((sender as CheckBox).DataContext) as ListBoxItem;
- if (checedItem != null) {
- checedItem.IsSelected = true;
- }
- } private void CheckBox_Unchecked(object sender, RoutedEventArgs e) {
- ListBoxItem checedItem = this.listBoxEmail.ItemContainerGenerator.ContainerFromItem((sender as CheckBox).DataContext) as ListBoxItem;
- if (checedItem != null) {
- checedItem.IsSelected = false;
- }
- }
- private void listBoxEmail_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- }
- private void stackPanel3_Hold(object sender, GestureEventArgs e)
- {
- for (int i = 0; i < lista.Count; i++)
- {
- ListBoxItem item = this.listBoxEmail.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
- StackPanel stack = findStackPanelCollapsed<StackPanel>(item);
- var collapsed = ((StackPanel) stack.Children.FirstOrDefault()).Children.FirstOrDefault();
- if (!this.isShowing)
- {
- collapsed.Visibility = System.Windows.Visibility.Visible;
- }
- else
- {
- collapsed.Visibility = System.Windows.Visibility.Collapsed;
- }
- }
- if (this.isShowing)
- {
- listBoxEmail.Margin = new Thickness(35, 155, 0, 0);
- this.isShowing = false;
- }
- else
- {
- listBoxEmail.Margin = new Thickness(-1, 155, 0, 0);
- this.isShowing = true;
- }
- }
- private T findStackPanelCollapsed<T>(DependencyObject parent) where T : DependencyObject
- {
- var count = VisualTreeHelper.GetChildrenCount(parent);
- if (count == 0)
- {
- return null;
- }
- else
- {
- var child = VisualTreeHelper.GetChild(parent, 0);
- if (child != null && child is T)
- {
- return (T)child;
- }
- else
- {
- var result = findStackPanelCollapsed<T>(child);
- if (result != null)
- {
- return result;
- }
- }
- }
- return null;
- }
- //private void stackpanel_tap(object sender, gestureeventargs e)
- //{
- // navigationservice.navigate(new uri(string.format("/mainpage.xaml"), urikind.relativeorabsolute));
- //}
- }
- public class MovieList : List<Email>
- {
- public MovieList(){
- Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
- Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
- Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
- Add(new Email() { Subject = " Billy Crystal vai apresentar o Oscar 2012", From = " i2testAndroid@gmail.com", Favoritar = "favorito_marcado.png", pubDate = "23:59" });
- }
- }
- public class Email{
- public string Subject { get; set; }
- public string Favoritar { get; set; }
- public string From { get; set; }
- public string pubDate { get; set; }
- }
- }
Add Comment
Please, Sign In to add comment