Manipulation Container not working in windows phone 8 - c#

I am trying to restrict the image movement placed inside a canvas on touch manipulation while translating, rotating and scaling(pinch to zoom).
I tried to implement manipulationcontainer property but it didn't give me the desired results.
Any help is appreciated!!!
XAMl Code-
<Canvas x:Name="mainCanvas" Grid.Column="1">
<Canvas.Background>
<ImageBrush x:Name="imgBg" ImageSource="/Images/Backgrounds/bg0.jpg"/>
</Canvas.Background>
<Image x:Name="imgTest" Source="/Images/Sample.jpg" ManipulationStarted="image_OnManipulationStarted" ManipulationDelta="image_OnManipulationDelta" Height="150" Width="190" Canvas.Top="80" Margin="12,0,0,0" Stretch="Fill">
<Image.RenderTransform>
<CompositeTransform />
</Image.RenderTransform>
</Image>
<Image x:Name="imgTest2" Source="/Images/Sample2.jpg" ManipulationStarted="image_OnManipulationStarted" ManipulationDelta="image_OnManipulationDelta" Height="150" Width="190" Canvas.Top="80" Canvas.Left="200" Margin="12,0,0,0" Stretch="Fill">
<Image.RenderTransform>
<CompositeTransform />
</Image.RenderTransform>
</Image>
<Image x:Name="imgTest3" Source="/Images/Sample3.jpg" ManipulationStarted="image_OnManipulationStarted" ManipulationDelta="image_OnManipulationDelta" Height="150" Width="190" Canvas.Top="240" Margin="12,0,0,0" Stretch="Fill">
<Image.RenderTransform>
<CompositeTransform />
</Image.RenderTransform>
</Image>
<Image x:Name="imgTest4" Source="/Images/Sample4.jpg" ManipulationStarted="image_OnManipulationStarted" ManipulationDelta="image_OnManipulationDelta" Height="150" Width="190" Canvas.Top="240" Canvas.Left="200" Margin="12,0,0,0" Stretch="Fill">
<Image.RenderTransform>
<CompositeTransform />
</Image.RenderTransform>
</Image>
</Canvas>
C# Code-
double _scaleX, _scaleY, _translationX, _translationY;
private void image_OnManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
// the user has started manipulating the screen, set starting points
var transform = (CompositeTransform)((System.Windows.FrameworkElement)(sender)).RenderTransform;
_scaleX = transform.ScaleX;
_scaleY = transform.ScaleY;
_translationX = transform.TranslateX;
_translationY = transform.TranslateY;
e.ManipulationContainer = mainCanvas;
e.Handled = true;
}
private void image_OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
var transform = (CompositeTransform)((FrameworkElement)(sender)).RenderTransform;
Image imgSender = sender as Image;
// pan
transform.TranslateX = _translationX + e.CumulativeManipulation.Translation.X;
transform.TranslateY = _translationY + e.CumulativeManipulation.Translation.Y;
if (e.PinchManipulation != null)
{
// zoom
transform.CenterX = e.PinchManipulation.Original.Center.X;
transform.CenterY = e.PinchManipulation.Original.Center.Y;
transform.ScaleX = _scaleX * e.PinchManipulation.CumulativeScale;
transform.ScaleY = _scaleY * e.PinchManipulation.CumulativeScale;
//rotate
transform.Rotation = angleBetween2Lines(e.PinchManipulation.Current, e.PinchManipulation.Original);
}
Point p = new Point(0, 0);
Rect containingRect = new Rect(p,((FrameworkElement)e.ManipulationContainer).RenderSize);
Rect shapeBounds = imgSender.RenderTransform.TransformBounds(new Rect(p,imgSender.RenderSize));
Point bound = new Point(shapeBounds.Top, shapeBounds.Bottom);
if (e.IsInertial && !containingRect.Contains(bound))
{
e.Complete();
}
e.Handled = true;
}

Keeping the parent canvas as a child of ScrollViewer worked for me.

Related

Canvas RuleLines With grid UWP

I'm working in a program which contains a canvas ,
This canvas includes some shapes and RuleLines ,
I added a grid to the canvas and it looked like this
the problem is the program is not smooth when I Manipulate or Zoom this canvas,
this is the Grid code in C# :
public void GridPartitions (Grid grid)
{
for (int ii = 0; ii < 50; ii++)
{
MyGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(20) });
MyGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) });
}
for (int row = 0; row < 50; row++)
{
for(int coulmn = 0; coulmn < 50; coulmn++)
{
var PartitionRectangle = new Rectangle();
PartitionRectangle.Stroke = new SolidColorBrush() { Color = Color.FromArgb(255, 0, 0, 0) };
PartitionRectangle.StrokeThickness = 0.2;
grid.Children.Add(PartitionRectangle);
Grid.SetRow(PartitionRectangle, row);
Grid.SetColumn(PartitionRectangle, coulmn);
}
}
}
However in Microsoft OneNote UWP
it has this option and it runs very smooth whatever the the number of the RuleLines and looks like this :
Any ideas to Improve My Code ?
Thank You.
here is My new Code .. Its better But still not smooth
I tried to Make everything in OOP as much as possible
XAML:
<Canvas Name="MyCanvas01" Background="Transparent"
MinWidth="2500" MinHeight="720"
Width="2500" Height="720"
HorizontalAlignment="Left" VerticalAlignment="Top"
RenderTransformOrigin="0.5,0.5"
ManipulationDelta="MyCanvas01_ManipulationDelta" ManipulationMode="All"
SizeChanged="MyCanvas01_SizeChanged">
<ItemsControl ItemsSource="{x:Bind HorizontalLines}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Line X1="{Binding From.X}" Y1="{Binding From.Y}"
X2="{Binding ElementName=MyCanvas01, Path=Width}" Y2="{Binding To.Y}"
Stroke="black" StrokeThickness="0.5"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl ItemsSource="{x:Bind VerticalLines}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Line X1="{Binding From.X}" Y1="{Binding From.Y}"
X2="{Binding To.X }" Y2="{Binding ElementName=MyCanvas01, Path=Height}"
Stroke="black" StrokeThickness="0.5"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="st01"/>
<TranslateTransform x:Name="TT01" />
</TransformGroup>
</Canvas.RenderTransform>
</Canvas>
C#:
public void DrawMissingLines(ObservableCollection<LineBindingPointsClass> lines, double missingLines, Point from, Point to ,int gg)
{
if (missingLines > 0)
{
for (int ii = 0; ii < missingLines; ii++)
{
lines.Add(new LineBindingPointsClass() { From = from , To = to });
if (gg == 1)
{
from.X += 25;
to.X += 25;
}
else if (gg == 2)
{
from.Y += 25;
to.Y += 25;
}
}
}
else if (missingLines < 0)
{
for (int ii = 0; ii < -missingLines; ii++)
{
lines.Remove(lines.Last());
}
}
}
private void MyCanvas01_SizeChanged(object sender, SizeChangedEventArgs e)
{
Canvas SizedCanvas = (Canvas)sender;
double missingVerticalLines, MissingHorizontalLines;
missingVerticalLines = (Math.Floor(SizedCanvas.Width) - VerticalLines.Count() * 25 ) / 25;
MissingHorizontalLines = (Math.Floor(SizedCanvas.Height) - HorizontalLines.Count() * 25) / 25;
DrawMissingLines(VerticalLines, missingVerticalLines,
new Point(VerticalLines.Count()*25 , 0),
new Point(VerticalLines.Count() * 25 , SizedCanvas.Height ),1);
DrawMissingLines(HorizontalLines, MissingHorizontalLines
, new Point(0,HorizontalLines.Count() * 25 ),
new Point( SizedCanvas.Width, HorizontalLines.Count() * 25) ,2);
}
For smooth zooming and Support gestures and (Ctrl + MouseWheel) you can put the canvas inside ScrollViewer.
Here is example Code:
<ScrollViewer ZoomMode="Enabled" ZoomSnapPointsType="Mandatory">
<Canvas Background="White" RenderTransformOrigin="0.5,0.5"
ManipulationDelta="MyCanvas_ManipulationDelta" ManipulationMode="All" CacheMode="BitmapCache">
<Rectangle Width="500" Height="500" Fill="Black"/>
</Canvas>
</ScrollViewer>
actually its very smooth
Now I'm working on adding adaptive Grid
here is the final code
working perfect
smooth and adaptive ,the background grids are updating according to the Canvas size change
I added two borders
the background is LinearGradientBrush for each border ,,........
enough talking and here is the Code:
<ScrollViewer Name="BorderScrollViewer" ZoomMode="Enabled" ZoomSnapPointsType="Mandatory"
HorizontalScrollMode="Disabled"
VerticalScrollMode="Disabled"
VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
ManipulationDelta="MyCanvas01_ManipulationDelta" ManipulationMode="All">
<Canvas Name="MyCanvas01" Background="White"
MinWidth="1200" MinHeight="720"
Width="1200" Height="720"
HorizontalAlignment="Left" VerticalAlignment="Top"
RenderTransformOrigin="0.5,0.5"
ManipulationDelta="MyCanvas01_ManipulationDelta" ManipulationMode="All"
SizeChanged="MyCanvas01_SizeChanged"
>
<Border VerticalAlignment="Stretch"
Width="{Binding ElementName=MyCanvas01,Path=Width}"
Height="{Binding ElementName=MyCanvas01,Path=Height}">
<Border.Background>
<LinearGradientBrush EndPoint="25,0" SpreadMethod="Repeat" MappingMode="Absolute" StartPoint="-25,0">
<LinearGradientBrush.RelativeTransform>
<CompositeTransform CenterY="0.5" CenterX="0.5" />
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="Transparent" Offset="0.53"/>
<GradientStop Color="Transparent" Offset="0.48"/>
<GradientStop Color="#FF320064" Offset="0.49"/>
<GradientStop Color="#FF320061" Offset="0.51"/>
<GradientStop Color="#FF320068" Offset="0.51"/>
</LinearGradientBrush>
</Border.Background>
</Border>
<Border VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Width="{Binding ElementName=MyCanvas01,Path=Width}"
Height="{Binding ElementName=MyCanvas01,Path=Height}" >
<Border.Background>
<LinearGradientBrush EndPoint="0,25" SpreadMethod="Repeat" MappingMode="Absolute" StartPoint="0,-25">
<LinearGradientBrush.RelativeTransform>
<CompositeTransform CenterY="0.5" CenterX="0.5"/>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="Transparent" Offset="0.53"/>
<GradientStop Color="Transparent" Offset="0.48"/>
<GradientStop Color="#FF320064" Offset="0.49"/>
<GradientStop Color="#FF320061" Offset="0.51"/>
<GradientStop Color="#FF320068" Offset="0.51"/>
</LinearGradientBrush>
</Border.Background>
</Border>
<Canvas.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="TT01" />
</TransformGroup>
</Canvas.RenderTransform>
</Canvas>
</ScrollViewer>

Unable to cast object of type 'System.Windows.Controls.Grid' to type 'System.Windows.Shapes.Ellipse'?

I'm implementing a drag and drop wpf application and i have created 3 ellipse, i'm using thumb control to drag and drop the ellipse in the map, and i wish to get the drop position for ellipse. However i get an error when drag ellipse as below:
Unable to cast object of type 'System.Windows.Controls.Grid' to type
'System.Windows.Shapes.Ellipse'
My XAML:
<Window x:Class="DragandDropMFP.MainWindow"
xmlns:local="clr-namespace:DragandDropMFP"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="maingrid" MouseMove="MainGrid_MouseMove">
<Grid.Background>
<ImageBrush ImageSource="/Map/Capture.Png" />
</Grid.Background>
<Canvas>
<Thumb Canvas.Left="38" Canvas.Top="22" DragDelta="Thumb_DragDelta">
<Thumb.Template>
<ControlTemplate>
<Viewbox Width="50" Height="50">
<Grid Width="20" Height="20">
<Ellipse
Fill="Blue"
MouseMove="DragMouseMove"/>
<TextBlock HorizontalAlignment="Center" Text="Printer1" FontSize="4" TextAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Viewbox>
</ControlTemplate>
</Thumb.Template>
</Thumb>
<Thumb Canvas.Left="37" Canvas.Top="100" DragDelta="Thumb_DragDelta">
<Thumb.Template>
<ControlTemplate>
<Viewbox Width="50" Height="50">
<Grid Width="20" Height="20">
<Ellipse Fill="Yellow"
MouseMove="DragMouseMove"/>
<TextBlock HorizontalAlignment="Center" Text="Printer2" FontSize="4" TextAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Viewbox>
</ControlTemplate>
</Thumb.Template>
</Thumb>
<Thumb Canvas.Left="37" Canvas.Top="174" DragDelta="Thumb_DragDelta">
<Thumb.Template>
<ControlTemplate>
<Viewbox Width="50" Height="50">
<Grid Width="20" Height="20">
<Ellipse Fill="Red"
MouseMove="DragMouseMove"/>
<TextBlock HorizontalAlignment="Center" Text="Printer3" FontSize="4" TextAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Viewbox>
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Canvas>
<TextBlock x:Name="ctlStatus" HorizontalAlignment="Stretch" Height="30" TextWrapping="Wrap" Text="status" VerticalAlignment="Bottom" RenderTransformOrigin="0.495,-4.7" />
</Grid>
</Window>
My xaml.cs :
public MainWindow()
{
InitializeComponent();
}
private void MainGrid_MouseMove(object sender, MouseEventArgs e)
{
Mouse.OverrideCursor = Cursors.Arrow;
objmoveposition(sender, e);
}
private void DragMouseMove(object sender, MouseEventArgs e)
{
Mouse.OverrideCursor = Cursors.Hand;
objmoveposition(sender, e);
}
private void objmoveposition(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
if (Mouse.OverrideCursor == Cursors.Hand)
{
Ellipse objTextbox = (Ellipse)sender; <--Error
if (objTextbox != null)
{
//----< Move Control >----
Point mousePoint = e.GetPosition(this);
//< Vertical >
int posY = (int)mousePoint.Y;
int actHeight = (int)Application.Current.MainWindow.Height;
int margin_Bottom = actHeight - (posY + (int)objTextbox.Height + (int)SystemParameters.CaptionHeight + (int)SystemParameters.BorderWidth + 4);
//< Horizontal >
int posX = (int)mousePoint.X;
int actWidth = (int)Application.Current.MainWindow.Width;
int margin_Right = actWidth - (posX + (int)objTextbox.Width + (int)SystemParameters.BorderWidth);
ctlStatus.Text = "Top=" + posY + " margin_bottom=" + margin_Bottom + " WinHeigth=" + actHeight + Environment.NewLine + " Left=" + posX + " margin_Right=" + margin_Right + "WinWidth=" + actWidth;
//ctlStatus.Text = "position=" + objTextbox.ActualHeight;
}
}
}
}
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
UIElement thumb = e.Source as UIElement;
Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange);
Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange);
}
Output:
Your guidance is highly appreciated!
Thanks!
The sender is the ellipse that raised the event, so you can replace this:
Ellipse objTextbox = ellipse1;
with this;
Ellipse objTextbox = (Ellipse)sender;
As long as you only assign the event to ellipses this is safe. If it gets assigned to other object types you'll need to check the type of sender before casting.
You don't need the name of the object.
Just found out by changing the Ellipse to Grid and everything works like cham..
Ellipse objTextbox = (Ellipse)sender;
change to
Grid objTextbox = (Grid)sender;
Thanks!

Wpf Text marquee behind other element

I built an messagebar, with an animated text,
see the .gif from the animation.
Like you can see the text "fly's" in the foreground and hides the placeholder. But I need the placeholder in the foreground.
My first idea was to change the region of the animation from
doubleAnimation.To = tbInfo.ActualWidth *-1;
to
doubleAnimation.To = boLogo.ActualWidth;
but the result looks like this: version with other animation area.
How can I set the placeholder in the foreground, so that the animation "fly's" behind it?
My XAML-Code
<Canvas x:Name="canMain" HorizontalAlignment="Stretch" VerticalAlignment="Center">
<Border x:Name="boLogo" Height="40" Background="Gray" Canvas.Left="0" Canvas.Top="-20">
<Button Content="Placeholder" Width="90" />
</Border>
<TextBlock x:Name="tbInfo" Visibility="Hidden" FontSize="32" FontWeight="Bold" Padding="5" HorizontalAlignment="Stretch" VerticalAlignment="Center"></TextBlock>
</Canvas>
and the code to show the window
public void ShowWindow(string str)
{
tbInfo.Text = str;
this.Height = 39;
this.Width = SystemParameters.WorkArea.Width;
this.Left = SystemParameters.PrimaryScreenWidth - this.Width;
this.Show();
TextMarquee(20);
}
private void TextMarquee(int duration)
{
double height = canMain.ActualHeight - tbInfo.ActualHeight;
tbInfo.Margin = new Thickness(0, height / 2, 0, 0);
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = canMain.ActualWidth;
doubleAnimation.To = tbInfo.ActualWidth * -1;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(duration));
tbInfo.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
tbInfo.Visibility = Visibility.Visible;
}
Use the Panel.ZIndex:
<Canvas x:Name="canMain" >
<Border x:Name="boLogo" Panel.ZIndex="2">
<Button Content="Placeholder" Width="90" />
</Border>
<TextBlock x:Name="tbInfo" Panel.ZIndex="1"></TextBlock>
</Canvas>
https://msdn.microsoft.com/de-de/library/system.windows.controls.panel.zindex%28v=vs.110%29.aspx
Try the Grid.ZIndex:
<Grid x:Name="canMain" >
<Border x:Name="boLogo" Grid.ZIndex="2">
<Button Content="Placeholder" />
</Border>
<TextBlock x:Name="tbInfo" Grid.ZIndex="1"/>
</Grid>
Being ZIndex = "2" the most visible layer.

How to animate grid in canvas

I have canvas. In canvas i have 3 grids. And I can't animate them. I want to make slideshow with grids.
Here my xamll code:
<Canvas x:Name="canvas1" Width="200" Height="300" Background="AliceBlue">
<Grid Canvas.Left="0" Canvas.Right="200" Background="Red" Name="grid1">
</Grid>
<Grid Canvas.Left="200" Canvas.Right="400" Background="Blue" Name="grid2">
</Grid>
<Grid Canvas.Left="400" Canvas.Right="600" Background="Black" Name="grid3">
</Grid>
<Button Panel.ZIndex="1" Width="50" Height="50" Content="NEXT" Click="Button_Click">
</Button>
</Canvas>
Here my c# code:
private void Button_Click(object sender, RoutedEventArgs e)
{
TranslateTransform trans = new TranslateTransform();
TranslateTransform trans2 = new TranslateTransform();
grid1.RenderTransform = trans;
grid2.RenderTransform = trans2;
Storyboard storyboard = new Storyboard();
DoubleAnimation da = new DoubleAnimation();
DoubleAnimation da1 = new DoubleAnimation();
da = new DoubleAnimation(200, 0, TimeSpan.FromSeconds(1));
da1 = new DoubleAnimation(0, -200, TimeSpan.FromSeconds(1));
Storyboard.SetTarget(da1, grid1);
Storyboard.SetTargetProperty(da1, new PropertyPath("RenderTransform.(TranslateTransform.X)"));
Storyboard.SetTarget(da, grid2);
Storyboard.SetTargetProperty(da, new PropertyPath("RenderTransform.(TranslateTransform.X)"));
storyboard.Children.Add(da1);
storyboard.Children.Add(da);
//this.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace, true);
FrameworkElement sd = new FrameworkElement();
sd.BeginStoryboard(storyboard, HandoffBehavior.Compose, true);
}
For now, i want to animate only 2 grids. i press button, and nothing happened.
I need to animate from the code.
That's how I do it:
Fist the button outside of the Canvas and place the Canvas in a Grid that has a Clip with the size of the objects inside the Canvas, I set 200x200 as example:
<Grid Width="200" Height="200">
<Grid.Clip>
<RectangleGeometry Rect="0,0,200,200"/>
</Grid.Clip>
<Canvas x:Name="canvas1" Background="AliceBlue" >
<Canvas.RenderTransform>
<TranslateTransform/>
</Canvas.RenderTransform>
<Grid Canvas.Left="0" Canvas.Right="200" Width="200" Height="200" Background="Red" Name="grid1">
</Grid>
<Grid Canvas.Left="200" Canvas.Right="400" Width="200" Height="200" Background="Blue" Name="grid2">
</Grid>
<Grid Canvas.Left="400" Canvas.Right="600" Width="200" Height="200" Background="Black" Name="grid3">
</Grid>
<Grid Canvas.Left="400" Canvas.Right="600" Width="200" Height="200" Background="Orange" Name="grid4">
</Grid>
</Canvas>
<Button VerticalAlignment="Bottom" Width="50" Height="50" Content="NEXT" Click="Button_Click">
</Button>
</Grid>
And now the logic for the button event
private void Button_Click(object sender, RoutedEventArgs e)
{
var offsetX = (canvas1.RenderTransform as TranslateTransform).X;
var finalX = offsetX - 200;
Storyboard sb = new Storyboard();
var da = new DoubleAnimation(offsetX, finalX, TimeSpan.FromSeconds(1));
Storyboard.SetTarget(da, canvas1);
Storyboard.SetTargetProperty(da, new PropertyPath("RenderTransform.(TranslateTransform.X)"));
sb.Children.Add(da);
sb.Begin();
}
I think is easy to understand and just one storyboard.
I hope it is the solution for your case.

limit image movement inside canvas

In windows 8 application, I am dragging an image inside a canvas. I want to bound that image inside canvas. How can I do it?
Here is my code:
XAML
<Canvas x:Name="canvas1" Grid.Row="0" Grid.Column="0" Margin="0" Grid.ColumnSpan="2" Grid.RowSpan="2" Background="White" >
<Image x:Name="image1" Height="100" Width="100" Margin="0" HorizontalAlignment="Left" ManipulationDelta="Image_ManipulationDelta_1" ManipulationMode="All">
<Image.RenderTransform>
<CompositeTransform/>
</Image.RenderTransform>
</Image></Canvas>`
C#
private void Image_ManipulationDelta_1(object sender, ManipulationDeltaRoutedEventArgs e)
{
var imag = (CompositeTransform)image1.RenderTransform;
imag.TranslateX += e.Delta.Translation.X;
imag.TranslateY += e.Delta.Translation.Y;}
You already have the code:
CompositeTransform imgTrans = image1.TransformToVisual(canvas1);
Windows.Foundation.Point imgPoint = imgTrans.TransformPoint(new Windows.Foundation.Point());
var imag = (CompositeTransform)image1.RenderTransform;
if (imgPoint.X <= 0)
{
imag .TranslateX -= imgPoint.X + 5;
imag .TranslateY += e.Delta.Translation.Y;
}

Categories

Resources