public ToolBarFilters (FilterTypes filter)
		{
			BindingContext = new FilterViewModel(filter);
			Title = ViewModel.Title;
		

			listView = new ListView () {
				ItemsSource = ViewModel.Items,
				BackgroundColor = Color.Transparent,
				ItemTemplate = new DataTemplate (() => {
					Label titleLabel = new Label ();
					titleLabel.VerticalOptions = LayoutOptions.Center;
					titleLabel.SetBinding (Label.TextProperty, "Name");

					Image blueCheck = new Image ();
					blueCheck.Source = "corningimages/selected.png";
					blueCheck.WidthRequest = 18;
					blueCheck.HeightRequest = 18;
					blueCheck.HorizontalOptions = LayoutOptions.EndAndExpand;
					blueCheck.SetBinding (Image.IsVisibleProperty, "IsSelected");

					return new ViewCell {
						View = new StackLayout {
							Orientation = StackOrientation.Horizontal,
							HorizontalOptions = LayoutOptions.StartAndExpand,
							Padding = new Thickness(20,0,10,0),
							Children = { titleLabel, blueCheck }
						}
					};
				})
			};
					

			listView.ItemSelected += (sender, e) =>
			{
				if (e.SelectedItem == null)
					return;

				var item =(MultiSelectSource)e.SelectedItem;
				if(filter == FilterTypes.Categories){
					GlobalVariables.SelectedCategory = item.Name;
					GlobalVariables.SelectedCategoryCode = item.Code;
				} else {
					GlobalVariables.SelectedLanguage = item.Code;
				}
				Navigation.PopModalAsync (true);
			};


			Content = new StackLayout { 
				Children = {
					listView
				}
			};

			this.ToolbarItems.Add (new ToolbarItem (Translation.Localize("DoneLabel"), null, () => {
				Navigation.PopModalAsync (true);
			}));
		}
        public AboutCorning()
        {
            //NavigationPage.SetTitleIcon (this, "corning_logo.png");
            //NavigationPage.SetHasNavigationBar (this, false);
            NavigationPage.SetBackButtonTitle(this,Translation.Localize("BackButton"));

            listView = new ListView {
                HasUnevenRows = true,
                ItemTemplate = new DataTemplate (typeof(ListViewCellTemplate)),
                SeparatorColor = Color.Transparent,
            };

            headerLayout = new StackLayout {
                Children = {
                    new Image {
                        //BackgroundColor = Color.FromHex("#006699"),
                        Source = "corningimages/corninglogo.png",
                        WidthRequest = 200,
                        HeightRequest = 200
                    }
                }
            };
            listView.Header = headerLayout;

            listView.BackgroundColor = Color.Transparent;

            listView.ItemTapped += (sender, e) => {
                if (e.Item != null) {
                    var fileItem = ((CorningLinks)listView.SelectedItem);
                    listView.SelectedItem = null;
                    var page = (Page)Activator.CreateInstance (typeof(WebPage), fileItem);
                    this.Navigation.PushAsync (page, true);
                }
            };

            Content = new StackLayout {
                Padding = 0,
                Children = {
                    ControlUtilities.GetAppHeader (),
                    GetBreadCrumbs (),
                    listView
                },
            };
            this.BackgroundImage = ImageConstants.backgroundImage;
        }
        void SwitchLayouts(LayoutType layoutType)
        {
            if (layoutType == LayoutType.ListLayout) {
                if (listView == null) {
                    listView = new ListView {
                        BackgroundColor = Color.White,
                        HasUnevenRows = true,
                        ItemTemplate = new DataTemplate (typeof(DocumentsCellTemplate)),
                        ItemsSource = ViewModel.ImageFiles,
                        SeparatorColor = Color.Transparent,
                    };
                    //listView.ItemsSource = ViewModel.Files;
                    listView.BackgroundColor = Color.Transparent;

                    listView.ItemTapped += (sender, e) => {
                        var fileItem = (Downloads)e.Item;
                        var page = new DocumentDetails (fileItem);
                        this.Navigation.PushAsync (page, true);
                    };
                }
                contentLayout = new StackLayout {
                    Children = {
                        listView,
                    }
                };

            } else {
                if (imageGrid == null) {
                    Device.OnPlatform (iOS: () => {
                        imageGrid = new GridView {
                            RowSpacing = 5,
                            Padding = 5,
                            ColumnSpacing = 5,
                            WidthRequest = App.ScreenWidth,
                            HeightRequest = App.ScreenHeight,
                            ItemWidth = UIConstants.GetGridViewItemWidths (),
                            ItemHeight = UIConstants.GetGridViewItemHeights (),
                            ItemsSource = ViewModel.ImageFiles,
                            ItemTemplate = new DataTemplate (typeof(GridViewCellTemplate)),
                        };
                    },
                        Android: () => {
                            imageGrid = new GridView {
                                Padding = 20,
                                RowSpacing = 20,
                                ColumnSpacing = 20,
                                ItemWidth = 500,
                                ItemHeight = 732,
                                ItemsSource = ViewModel.ImageFiles,
                                ItemTemplate = new DataTemplate (typeof(DynamicDocsTemplateLayout)),
                                IsClippedToBounds = true,
                            };
                        });

                    imageGrid.ItemSelected += (sender, e) => {
                        var fileItem = (Downloads)e.Value;
                        var page = new DocumentDetails (fileItem);
                        this.Navigation.PushAsync (page, true);
                    };
                } else {
                    imageGrid.WidthRequest = screenwidth;
                    imageGrid.HeightRequest = screenheight;
                }
                contentLayout = new StackLayout {
                    Children = {
                        imageGrid,
                    }
                };

            }
            this.Content = contentLayout;
        }
        public SearchView(LibraryType type)
        {
            //this.BackgroundImage = ImageConstants.backgroundImage;
            BindingContext = new SearchViewModel ();
            categoryType = type;

            var searchBar = new SearchBar ();
            searchBar.SearchButtonPressed += OnSearchBarButtonPressed;
            searchBar.TextChanged += (sender, e) => {
                //var changedSearchBar = (SearchBar)sender;
                if (e.NewTextValue == null) {
                    //this only happens when user taps "Cancel" on iOS
                    ViewModel.LoadItemsCommand.Execute (null);
                    searchlistView.ItemsSource = ViewModel.SearchItems;
                    searchlistView.IsVisible = true;
                    resultlistView.IsVisible = false;
                }
            };

            searchlistView = new ListView () {
                HasUnevenRows = true,
                ItemTemplate = new DataTemplate (typeof(SearchItemTemplate)),
                SeparatorColor = Color.Transparent,
                BackgroundColor = Color.Transparent,
            };

            resultlistView = new ListView () {
                HasUnevenRows = true,
                ItemTemplate = new DataTemplate (typeof(ResultsItemTemplate)),
                //SeparatorColor = Color.Transparent,
                BackgroundColor = Color.Transparent,
            };

            searchlistView.ItemTapped += (sender, e) => {
                var search = (Search)e.Item;
                ViewModel.SearchText = search.SearchText;

                if(categoryType != LibraryType.MyDocuments){
                    ViewModel.LoadResultsCommand.Execute (null);
                    resultlistView.ItemsSource = ViewModel.Files;
                }
                else{
                    ViewModel.LoadDownloadedSearchResultsCommand.Execute (null);
                    resultlistView.ItemsSource = ViewModel.DownloadedFiles;
                }

                searchlistView.IsVisible = false;
                resultlistView.IsVisible = true;
            };

            resultlistView.ItemTapped += (sender, e) => {
                if(categoryType == LibraryType.MyDocuments){
                    var fileItem = (Downloads)e.Item;
                    var page = new DocumentDetails (fileItem);
                    this.Navigation.PushAsync (page,true);
                }
                else{
                    var fileItem = (ProductCatalog)e.Item;
                    var page = new DetailsPopup (fileItem,type);
                    this.Navigation.PushAsync (page,true);
                }
            };

            Content = new PopupLayout {
                //VerticalOptions = LayoutOptions.Center,
                Content = new StackLayout {
                    //BackgroundColor = Color.Black,
                    Children = { searchBar, searchlistView, resultlistView }
                }
            };

            resultlistView.IsVisible = false;
            Title = Translation.Localize("SearchLabel");
        }
		public DummyView ()
		{
			
			BindingContext = new BaseViewModel ();
			//ViewModel.IsRunning = true;
			NavigationPage.SetHasNavigationBar (this, false);
			this.BackgroundImage = ImageConstants.backgroundImage;	


			var list = new ListView {
				HasUnevenRows = true,
				SeparatorColor = Color.Transparent,
			};
			list.BackgroundColor = Color.Transparent;
			Device.OnPlatform 
			(
				iOS: () => { 
					grid = new Grid {
						VerticalOptions = LayoutOptions.Center,
						HorizontalOptions = LayoutOptions.Center,
						RowDefinitions = {
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
						},
						ColumnDefinitions = {
							new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
						}
					};

					grid.Children.Add (ControlUtilities.GetAppHeader (), 0, 0);
					grid.Children.Add (list, 0, 1);
					grid.Children.Add (CreateLoadingIndicator (), 0, 1);
				},
				Android: () => {

					grid = new Grid {
						VerticalOptions = LayoutOptions.Center,
						HorizontalOptions = LayoutOptions.Center,
						RowDefinitions = {
							new RowDefinition { Height = GridLength.Auto },
							//new RowDefinition { Height = GridLength.Auto },
						},
						ColumnDefinitions = {
							new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
						}
					};

					//grid.Children.Add (ControlUtilities.GetAppHeader (), 0, 0);
					grid.Children.Add (list, 0, 0);
					grid.Children.Add (CreateLoadingIndicator (), 0, 0);
				},
				WinPhone: () => {
					grid = new Grid {
						VerticalOptions = LayoutOptions.Center,
						HorizontalOptions = LayoutOptions.Center,
						RowDefinitions = {
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
						},
						ColumnDefinitions = {
							new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
						}
					};

					grid.Children.Add (ControlUtilities.GetAppHeader (), 0, 0);
					grid.Children.Add (list, 0, 1);
					grid.Children.Add (CreateLoadingIndicator (), 0, 1);
				}
			);
				
			Content = grid;
		}
        void SwitchLayouts(LayoutType layoutType)
        {
            if (layoutType == LayoutType.ListLayout) {
                if (listView == null) {
                    listView = new ListView {
                        BackgroundColor = Color.White,
                        HasUnevenRows = true,
                        ItemTemplate = new DataTemplate (typeof(NewsLetterCellTemplate)),
                        SeparatorColor = Color.Transparent,
                    };
                    listView.ItemsSource = ViewModel.Files;
                    listView.BackgroundColor = Color.Transparent;

                    listView.ItemTapped += (sender, e) => {
                        ((ListView)sender).SelectedItem = null;
                    };

                    listView.ItemSelected += (sender, e) => {
                        if (e.SelectedItem == null)
                            return;

                        var currentItem = (ProductCatalog)e.SelectedItem;
                        var page = new DetailsPopup (currentItem, LibraryType.NewsLetter);
                        this.Navigation.PushAsync (page, false);
                    };

                }

                Device.OnPlatform
                (
                    iOS: () => {
                        grid = new Grid {
                            VerticalOptions = LayoutOptions.Center,
                            HorizontalOptions = LayoutOptions.Center,
                            RowDefinitions = {
                                new RowDefinition { Height = GridLength.Auto },
                            },
                            ColumnDefinitions = {
                                new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                            }
                        };
                    },
                    Android: () => {
                        grid = new Grid {
                            VerticalOptions = LayoutOptions.StartAndExpand,
                            HorizontalOptions = LayoutOptions.Center,
                            RowDefinitions = {
                                new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
                            },
                            ColumnDefinitions = {
                                new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                            }
                        };
                    },
                    WinPhone: () => {
                        grid = new Grid {
                            VerticalOptions = LayoutOptions.Center,
                            HorizontalOptions = LayoutOptions.Center,
                            RowDefinitions = {
                                new RowDefinition { Height = GridLength.Auto },
                            },
                            ColumnDefinitions = {
                                new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                            }
                        };
                    }
                );

                grid.Children.Add (listView, 0, 0);
                grid.Children.Add (CreateLoadingIndicator (), 0, 0);
                grid.Children.Add (ShowEmptyResults (), 0, 0);
                this.Content = grid;
            } else {
                if (imageGrid == null) {
                    Device.OnPlatform (iOS: () => {
                        imageGrid = new GridView {
                            RowSpacing = 5,
                            Padding = 5,
                            ColumnSpacing = 5,
                            WidthRequest = App.ScreenWidth - 20,
                            HeightRequest = App.ScreenHeight,
                            ItemWidth = UIConstants.GetGridViewItemWidths (),
                            ItemHeight = UIConstants.GetGridViewItemHeights (),
                            ItemsSource = ViewModel.ImageFiles,
                            ItemTemplate = new DataTemplate (typeof(GridViewCellTemplate)),
                        };
                    },
                        Android: () => {
                            imageGrid = new GridView {
                                Padding = 20,
                                RowSpacing = 20,
                                ColumnSpacing = 20,
                                ItemWidth = 500,
                                ItemHeight = 732,
                                ItemsSource = ViewModel.ImageFiles,
                                ItemTemplate = new DataTemplate (typeof(DynamicNewsLetterTemplateLayout)),
                                IsClippedToBounds = true,
                            };
                        });

                    imageGrid.ItemSelected += (sender, e) => {
                        var currentItem = (ProductCatalog)e.Value;
                        var fileItem = ViewModel.Files.ToList ().FirstOrDefault (i => i.Id == currentItem.Id);
                        var page = new DetailsPopup (fileItem, LibraryType.NewsLetter);
                        Navigation.PushAsync (page, true);
                    };

                }
                grid = new Grid {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    RowDefinitions = {
                        new RowDefinition { Height = GridLength.Auto },
                    },
                    ColumnDefinitions = {
                        new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                    }
                };

                grid.Children.Add (imageGrid, 0, 0);
                grid.Children.Add (CreateLoadingIndicator (), 0, 0);
                grid.Children.Add (ShowEmptyResults (), 0, 0);
                this.Content = grid;
            }
        }
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged ();

            dynamic c = BindingContext;

            // TODO: Fix book item vertical scroll issue - RowHeight - 1  = No Scroll

            var itemView = new ListView {
                //BackgroundColor = Color.Lime,
                ItemsSource = new List<dynamic> { c },
                ItemTemplate = new DataTemplate (typeof(ListTemplateLayout)),
                HasUnevenRows = false,
                IsPullToRefreshEnabled = false,
                HeightRequest = 244,
                VerticalOptions = LayoutOptions.FillAndExpand,
                SeparatorVisibility = SeparatorVisibility.None,
                InputTransparent = true,
                RowHeight = 243
            };

            itemView.ItemTapped += (sender, e) => {
                ((ListView)sender).SelectedItem = null;
            };

            itemView.ItemSelected += (sender, e) => {
                if (e.SelectedItem == null)
                    return;

                var currentItem = (ProductCatalog)e.SelectedItem;
                var page = new DetailsPopup (currentItem, LibraryType.NewsLetter);
                NewsletterView.Instance.Navigation.PushAsync (page, false);
            };

            View = itemView;
        }
        private ListView CreateLibraryListView()
        {
            categories = new ListView {
                HasUnevenRows = true,
                ItemTemplate = new DataTemplate (typeof(LibraryCellTemplate)),
                SeparatorColor = Color.Transparent,
            };

            var headerimage = new Image ();

            if (Device.Idiom == TargetIdiom.Phone) {
                headerimage.Source = Translation.Localize ("CorningLibraryImagePhone");
                if (App.CurrentDevice == IOSDevices.IPhone4S
                    || App.CurrentDevice == IOSDevices.IPhone5 || App.CurrentDevice == IOSDevices.IPhone5S) {
                    headerimage.HeightRequest = 130;
                } else {

                    headerimage.HeightRequest = 150;
                }
            } else {
                headerimage.Source = Translation.Localize ("CorningLibraryImagePad");
            }

            headerLayout = new StackLayout {
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                Children = {
                    headerimage
                }
            };
            categories.Header = headerLayout;

            categories.BackgroundColor = Color.Transparent;

            CreateEventHandlers (categories);
            return categories;
        }
        private void CreateEventHandlers(ListView listView)
        {
            listView.ItemTapped += (sender, e) => {
                ((ListView)sender).SelectedItem = null;
            };
            listView.ItemSelected += (sender, e) => {
                if (e.SelectedItem == null)
                    return;

                var item = (Category)e.SelectedItem;
                GlobalVariables.SelectedCategory = item.CategoryName;
                GlobalVariables.SelectedCategoryCode = item.CategoryCode;

                Navigation.PushAsync (new LibraryDetailsView (),false);
            };
        }