0

here is the basic model of the code I have:

private void textBlock1_Tap (object sender, System.Windows.Input.GestureEventArgs e)
{
    TextBox TextBox1 = new TextBox();
    TextBlock tblk = (TextBlock)sender;

    ApplicationBar = new ApplicationBar();

    TextBox1.LostFocus += TextBox1_LostFocus;

    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/check.png", UriKind.Relative));
    appBarButton.Text = "Accept";
    ApplicationBar.Buttons.Add(appBarButton);

    appBarButton.Click +=

}

void TextBox1_LostFocus(object sender, RoutedEventArgs e)
{
    //do things here
}

I need to subscribe to the click Event, and when it is triggered, I need TextBox1_LostFocus to be called and TextBox1 to be sent as a parameter. Basically what I want to do is make appBarButton.Click do the exact same thing as TextBox1.LostFocus.

Problem is, LostFocus is a RoutedEventHandler and TextBox1_LostFocus takes a RoutedEventArgs as a parameter while appBarButton.Click is an EventHandler.

I'm not very experienced in coding at all so any help is much appreciated!

Wilfred Wee
  • 371
  • 2
  • 17

1 Answers1

1

RoutedEventArgs inherits EventArgs.

You can add the same handler to both events.

Better yet, you can move the code to a function and call it from two different event handlers.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Thanks for the reply. So far, here is my idea of implementing it: 1. Change the 2nd parameter of TextBox1_LostFocus to EventArgs 2. line of code to handle click event: appBarButton.Click += new EventHandler(TextBox1_LostFocus(TextBox1, )); I have no idea how to proceed. – Wilfred Wee Jun 16 '13 at 22:55
  • Got it! http://stackoverflow.com/questions/8644253/pass-parameter-to-eventhandler – Wilfred Wee Jun 16 '13 at 23:18