Reputation: 680
Using code (shown below) I have got an error that say this:
'object' does not contain a definition for 'RenderTransform' and no extension method 'RenderTransform' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly language
I have no idea why this is showing as an error as according to most examples (of this) this should work. Code:
public void Rotate(object sender, int rotationAmount, int centerX, int centerY)
{
RotateTransform rotate = new RotateTransform(rotationAmount);
rotateTransform.CenterX = centerX;
rotateTransform.CenterY = centerY;
sender.RenderTransform = rotateTransform;
}
Upvotes: 1
Views: 73
Reputation: 186803
You have to cast sender
(which is declared as object
) to appropriate type:
UIElement element = sender as UIElement;
if (element != null)
element.RenderTransform = rotateTransform;
Upvotes: 2
Reputation: 26876
Your sender
has type object
, which definitely has no RenderTransform
method.
You should cast it to the type you needed.
Upvotes: 0
Reputation: 101701
You need to cast sender
to a type that has RenderTransform
property.
Upvotes: 0