I’m trying to create an on event action, that can be reused for a number of objects.
To achieve this I’m storing the name of the target object in the Tag property.
So on event this is triggered:
private void ShowDeleteButton(object sender, System.Windows.Input.MouseEventArgs e)
{
Duration TimeToTake = new Duration(new TimeSpan(0,0,0,0,300));
DoubleAnimation ShowButton = new DoubleAnimation(0, 104, TimeToTake);
DoubleAnimation HideButton = new DoubleAnimation(104, 0, TimeToTake);
(sender as Rectangle).Tag.BeginAnimation(Button.WidthProperty, ShowButton);
}
Obviously using (sender as button).Tag as the name for the object will not work. So how can I convert the tag property to work as a reference for the target object?
Note this is WPF
Thanks
For WPF, use FindName:
For WinForms, you can find the control by the name that is stored in the Tag: