예제 #1
0
        internal static void Show(string photo, object itemSource, Func <object, bool, Uri> photoGetter, Thickness margin, UIElement page)
        {
            if (_viewerInstance != null)
            {
                throw new InvalidOperationException("Already displaying a photoviewer popup");
            }

            _hostGrid = VisualTreeHelperExtensions.GetFirstDescendantOfType <Grid>(page);

            if (_hostGrid != null)
            {
                _viewerInstance = new ImagePopupViewer(photoGetter, photo);

                // dialog needs to span all rows in the grid
                _viewerInstance.SetValue(Grid.RowSpanProperty, (_hostGrid.RowDefinitions.Count > 0 ? _hostGrid.RowDefinitions.Count : 1));
                _viewerInstance.SetValue(Grid.ColumnSpanProperty, (_hostGrid.ColumnDefinitions.Count > 0 ? _hostGrid.ColumnDefinitions.Count : 1));

                _hostGrid.Children.Add(_viewerInstance);

                _viewerInstance.ItemsSource = itemSource;
            }
            else
            {
                throw new ArgumentException("can't find a top level grid");
            }
        }
예제 #2
0
        private void LoadData()
        {
            Func <object, bool, Uri> getImageForThumbnail = (o, large) =>
            {
                return(new Uri(((Thumbnail)o).ImageUrl));
            };

            ImagePopupViewer.Show(Model.Items[0].ImageUrl, Model.Items, getImageForThumbnail, new Thickness(50, 50, 50, 50), this);
        }
예제 #3
0
 private void ImagePopupViewer_Unloaded(object sender, RoutedEventArgs e)
 {
     if (_hostGrid != null)
     {
         ElementCompositionPreview.SetElementChildVisual(_hostGrid.Children[0], null);
         _hostGrid.Children.Remove(_viewerInstance);
         _hostGrid = null;
     }
     _viewerInstance = null;
 }
        internal static void Show(string photo, object itemSource, Func<object, bool, Uri> photoGetter, Thickness margin, UIElement page)
        {
            if (_viewerInstance != null)
            {
                throw new InvalidOperationException("Already displaying a photoviewer popup");
            }

            _hostGrid = VisualTreeHelperExtensions.GetFirstDescendantOfType<Grid>(page);

            if (_hostGrid != null)
            {
                _viewerInstance = new ImagePopupViewer(photoGetter, photo);

                // dialog needs to span all rows in the grid
                _viewerInstance.SetValue(Grid.RowSpanProperty, (_hostGrid.RowDefinitions.Count > 0 ? _hostGrid.RowDefinitions.Count : 1));
                _viewerInstance.SetValue(Grid.ColumnSpanProperty, (_hostGrid.ColumnDefinitions.Count > 0 ? _hostGrid.ColumnDefinitions.Count : 1));

                _hostGrid.Children.Add(_viewerInstance);

                _viewerInstance.ItemsSource = itemSource;
            }
            else
            {
                throw new ArgumentException("can't find a top level grid");
            }
        }
 private void ImagePopupViewer_Unloaded(object sender, RoutedEventArgs e)
 {
     if (_hostGrid != null)
     {
         ElementCompositionPreview.SetElementChildVisual(_hostGrid.Children[0], null);
         _hostGrid.Children.Remove(_viewerInstance);
         _hostGrid = null;
     }
     _viewerInstance = null;
 }