The following code won't work:
RoutedEventHandler handler = (sender, eventArgs) =>
{
var ui = sender as UIElement;
ui.Visibility = Visibility.Collapsed;
control.Click -= handler;
};
the compiler complains the handler is not initialized.
But this code will shut up the compiler:
RoutedEventHandler handler = null;
handler = (sender, eventArgs) =>
{
var ui = sender as UIElement;
ui.Visibility = Visibility.Collapsed;
control.Click -= handler;
};
funny.