Reputation: 143
Help me, please. I have this:
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Rectangle x:Name="MyObject" Fill="Red" ManipulationDelta="Object_ManipulationDelta" Height="80" Width="80" ManipulationMode="All">
<Rectangle.RenderTransform>
<CompositeTransform/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="Blue" Grid.Row="1">
<Rectangle.RenderTransform>
<CompositeTransform/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="Green" Grid.Column="1"/>
<Rectangle Fill="Yellow" Grid.Row="1" Grid.Column="1"/>
</Grid>
And I have function Object_ManipulationDelta
which change position of element if it is dragged.
Object_ManipulationDelta
for change location whole group if one of them is dragged? In function I use this: var obj = (CompositeTransform)MyObject.RenderTransform
and TranslateX
(and Y) for obj.<Rectangle.RenderTransform...
after each rectangle?Upvotes: 0
Views: 1189
Reputation: 10620
Just name the whole Grid you have mentioned in your code sample using x:Name="name" and apply the transformation on this Grid. Or group only the target rectangles in nested Grid and apply the transformation on it.
Upvotes: 1
Reputation: 1998
Any Panel such as Grid can do the grouping job. Grid has ManipulationDelta event too. To avoid duplicate Composite transform move it to a grid containing the rectangles.
Upvotes: 0