private void AttachPageEvents(Element element)
        {
            var viewCell = BaseUIHelper.GetContainingViewCell(element);

            if (viewCell != null)
            {
                viewCell.PropertyChanged += (s, ev) =>
                {
                    var propertyName = ev.PropertyName;

                    var test  = viewCell.BindingContext;
                    var test1 = Element.BindingContext;
                    var test2 = Control;

                    if (ev.PropertyName == "Renderer")
                    {
                        if (test == null || test1 == null)
                        {
                            return;
                        }

                        SetImageSource();
                    }
                };

                var listView = BaseUIHelper.GetContainingListView(element);
                if (listView != null)
                {
                    listView.PropertyChanged += (s, e) =>
                    {
                        if (e.PropertyName == "Renderer")
                        {
                            if (listView.Parent == null)
                            {
                                this.Dispose(true);
                            }
                        }
                    };
                }

                page = BaseUIHelper.GetContainingPage(element);
                if (page == null)
                {
                    var root = BaseUIHelper.GetRootElement(element);
                    root.PropertyChanged += (s, e) =>
                    {
                        if (e.PropertyName == "Parent")
                        {
                            AttachPageEvents(root);
                        }
                    };
                    return;
                }

                navigPage = BaseUIHelper.GetContainingNavigationPage(page);
                if (navigPage != null)
                {
                    navigPage.Popped += OnPagePopped;
                }
            }
        }
        private void AttachPageEvents(Xamarin.Forms.Element element)
        {
            var viewCell = BaseUIHelper.GetContainingViewCell(element);

            if (viewCell != null)
            {
                viewCell.PropertyChanged += (s, ev) =>
                {
                    var propertyName = ev.PropertyName;
                };

                var listView = BaseUIHelper.GetContainingListView(element);
                if (listView != null)
                {
                    listView.PropertyChanged += (s, e) =>
                    {
                        if (e.PropertyName == "Renderer")
                        {
                            if (listView.Parent == null)
                            {
                                this.Dispose(true);
                            }
                        }
                    };
                }

                page = BaseUIHelper.GetContainingPage(element);

                if (page != null)
                {
                    page.Disappearing += (s, ev) =>
                    {
                        //if (imageLoader != null)
                        {
                            //imageLoader.CancelDisplayTask(imageView);
                        }
                    };
                }

                if (page == null)
                {
                    var root = BaseUIHelper.GetRootElement(element);
                    root.PropertyChanged += (s, e) =>
                    {
                        if (e.PropertyName == "Parent")
                        {
                            AttachPageEvents(root);
                        }
                    };
                    return;
                }
                // As of Xamarin.Forms 1.4+, image will be reused when moving from tabs.
                // Uncomment this if using Xamarin.Forms < 1.4.
                //if (page.Parent is TabbedPage)
                //{
                //    page.Disappearing += PageContainedInTabbedPageDisapearing;
                //    return;
                //}

                navigPage = BaseUIHelper.GetContainingNavigationPage(page);
                if (navigPage != null)
                {
                    navigPage.Popped += OnPagePopped;

                    // As of Xamarin.Forms 1.4+, image will be reused when moving from tabs.
                    // Uncomment this if using Xamarin.Forms < 1.4.
                    //if (navigPage.Parent is TabbedPage)
                    //{
                    //    navigPage.Disappearing += PageContainedInTabbedPageDisapearing;
                    //}
                }
            }
            // As of Xamarin.Forms 1.4+, image will be reused when moving from tabs.
            // Uncomment this if using Xamarin.Forms < 1.4.
            //else if ((page = GetContainingTabbedPage(element)) != null)
            //{
            //    page.Disappearing += PageContainedInTabbedPageDisapearing;
            //}
        }