1

How do I transfer an additional parameter to the Tapped event?

 2 years ago
source link: https://www.codesd.com/item/how-do-i-transfer-an-additional-parameter-to-the-tapped-event.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How do I transfer an additional parameter to the Tapped event?

advertisements

I create 10 TextBlock programmatically in Windows phone app 8.1
Now i want to add Tapped event to each TextBlock and pass extra parameter to it so i can find which TextBlock is tapped

I uses this code to create TextBlock with Tapped event:

for (int i=1;i<11;i++)
{
    TextBlock txtName = new TextBlock();
    txtName.Tapped += TxtName_Tapped;
}

private void TxtName_Tapped(object sender, TappedRoutedEventArgs e)
{
    // Something
}

How can i pass extra parameter?


As @Ric suggested you can always do:

 private void TxtName_Tapped(object sender, TappedRoutedEventArgs e)
    {
        clickedElementName = ((TextBlock)sender).Name ;
        if(clickedElementName == "element1")
        {
        }
    }

Related Articles

Pass an additional parameter to the C # callback

How to add extra parameters to the following callback : objXmpp.OnLogin += new ObjectHandler(objXmppArun_OnLogin); private void objXmppArun_OnLogin(object sender) { } Is it possible to send one extra parameter to the objXmppArun_OnLogin event handler

Pass the parameter to the invoked event handler, that is, element.onchange (); javascript

I have a function like this: function doSomething() { // do something with select element } document.getElementById("selectel").onchange = doSomething; // Call onchange event document.getElementById("selectel").onchange(); Now, I recog

How do I add an additional argument to the GetJson callback?

I have following function: $.getJSON( "ajax/test.json", function( data ) { var items = []; $.each( data, function( key, val ) { ... }); } How can I pass additional parameter to function? I want something like this: var newParam = externalFunctio

Pass an additional parameter to the model using AngularJS

I have the following directive: app.directive("actTemplate", function() { return { restrict: 'A', templateUrl: "/views/myTemplate.html" }; }); how can i pass additional parameter to myTemplate so: <div> {{aditionalParam}} ... <

How do I pass an object parameter to an input event in Xamarin.Forms?

I have implemented a ListView that is binded to an ObservableCollection and I need to update each item when the entry fields are changed. I am using the completed event but it only passes the entry value to the completed event function and I don't kn

fb 'apprequests' redirects to a new URL or sends an additional parameter to the URL

I need to pass additional parameter to redirect url when the user accept fb app request or need to redirect user to a custom url. How can I do this?...Please see the following code. $('#sendRequest').click(function() { FB.ui( { method : 'apprequests'

How do I transfer a text file to the 2D table in C ++?

How can i transfer a text file(.txt) to array 2D in c++ and this is my source code fstream fin('textfile.txt', ios::in); int matrix[n][m]; // n is the number of rows and m is the number of columns for(int i = 0;i < n; i++){ for(int j = 0; j<m; j++){

Nativescript Angular: How to pass a button view as a parameter in a tap event?

My Nativescript Angular app dynamically returns data as a list of items. For each item, I use *ngFor to create a button with a tap event attached to it. I want to pass the button itself as a parameter as I need to add cssClass on tap. But I can't use

How can I add an additional object to the results of a LINQ query?

I have the following code that I need to add an additonal object to after the results have been retrieved from the databse. Any Ideas on how I might to this ? public IEnumerable<ProdPriceDisplay> GetShopProductsPrices() { //ProdPriceDisplay ProdPric

MVC 3 post template and additional parameter to the HttpPost action method using the Ajax form

Using ASP.NET MVC 3 and Razor, I have a strongly typed view against MyViewModel class. Within the view I have an AJAX form that consists of a group of radio buttons. Below it, I have a normal HTML form that collects data for MyViewModel. Depending on

Display an additional parameter on the event in fullcalendar

I am using the fullcalendar plugin for my angular application. I am using eventSource to get my events. I have title, start, end and breakCount keys in my JSON, like this: { "title": "06DefaultProgram2", "start": "2016-0

How to create the Tap event on the Long Tap gesture on UIWebView?

I have added Long Tap gesture on UIWebView. But I want UIWebView to process a standard Tap event before my Long Tap will be recognized. (Two gestures should be processed on Long Tap - a simple Tap and my Long Tap). How to do this? I think it's requir

How to stop a WPF binding by ignoring the PropertyChanged event?

I have a TextBox bound to a ViewModel's Text property with the following setup: Xaml <TextBox Text="{Binding Text}"/> C# public class ViewModel : INotifyPropertyChanged { public string Text { get { return m_Text; } set { if (String.Equals(

How do I call a Web service in the Application_Exit event?

How do I call a webservice in the Application_Exit event? private void Application_Exit(object sender, EventArgs e) { TestWSSoapClient.ReleaseUserCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(TestWSSoapClient_ReleaseUs

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK