void imageView_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { ShowImageView imageView = sender as ShowImageView; if (imageView == null) { return; } if (Math.Abs(e.CumulativeManipulation.Translation.Y) < 15) { e.Handled = true; if (e.CumulativeManipulation.Translation.X < -10) { Size size = imageView.RenderSize; Point center = imageView.PointToScreen(new Point(imageView.ActualWidth / 2, imageView.ActualHeight / 2)); ShowImageModel model = imageView.Model as ShowImageModel; if (model != null) { OnAddImageCommand(center, size, model.Text); } e.Complete(); } } }
private void GenerateImageControl(string uriPath) { ShowImageModel imageModel = new ShowImageModel(); imageModel.UriPath = uriPath; imageModel.Text = uriPath; Viewbox vb = new Viewbox(); vb.Width = 100; vb.Height = 100; vb.Margin = new Thickness(20.0); ShowImageView imageView = new ShowImageView(imageModel); imageView.Background = new SolidColorBrush(Colors.Transparent); vb.Child = imageView; imageView.IsManipulationEnabled = true; imageView.ManipulationDelta += imageView_ManipulationDelta; pnlControls.Children.Add(vb); }