Get bound object based on it's id

wpf get binding value programmatically
c# get binding
wpf binding source
xaml binding
uwp bind observablecollection
wpf converter
observablecollection in wpf mvvm
observablecollection<string

I have this textbox for clients to search for id:

Enter Id: <input type="text" [(ngModel)]="temp.id"> 
<button (click)="myEvent()">My Button</button>

<table class='table' *ngIf="collection">
<tbody>
    <tr *ngFor="let item of collection">
        <td>{{ item.id }}</td>
        <td>{{ item.name }}</td>
    </tr>
</tbody>

In the myEvent method, I don't know how should I get the relevant bound object of given Id, so that I get it's name property and send it to my WEB API:

temp: any = { id: '' };

myEvent() {
    this.http.get('url', {
        params: {
            id: this.temp.id,
            name: ???
        }
    })
}

If you have your collection of items, you can find the one by the id property a few ways.

Here is one way using the array find method:

myEvent() {
    const item = this.collection.find(i => i.id === this.temp.id);

    if (!item) {
        return;
    }
    ...
}

How to: Get the Binding Object from a Bound Target Property, In this article. Example; See also. This example shows how to obtain the binding object from a data-bound target property. This example shows how to obtain the binding object from a data-bound target property. Example. You can do the following to get the Binding object: // textBox3 is an instance of a TextBox // the TextProperty is the data-bound dependency property Binding myBinding = BindingOperations.GetBinding(textBox3, TextBox.TextProperty);

You could do something like this:

Enter Id: <input type="text" [(ngModel)]="temp.id"> 

<table class='table' *ngIf="collection">
<tbody>
   <tr *ngFor="let item of collection">
      <td>{{ item.id }}</td>
      <td>{{ item.name }}</td>
      <td><button (click)="myEvent(item)">My Button</button></td>
    </tr>
</tbody>

And get the selected item in your myEvent

myEvent(item: any) {
  this.http.get('url', {
      params: {
          id: item.id,
          name: item.name
    }
 })
}

How to: Produce a Value Based on a List of Bound Items, In the following example, NameListData refers to a collection of PersonName objects, which are objects that contain two properties, firstName  2D game with Unity. Have a parent game object, with several children objects scattered all over the scene. I want to calculate the bounding rectangle of the parent game object. Let the black dots be the children objects. The red rectangle is the bounding box. I am not really interested in the position - I only want the dimensions of such box.

You could use JavaScript's native method find() to get the exact object and access name field in component.ts

let name = this.collection.find(t=> t.id == this.temp.id).name; 

Then you should be able to pass the name with your I'd to the API.

[PDF] Real-World Objects Are Not Represented as Bound Units, and Vogel, this strong object-based account of working memory representations they might have more bound representations than objects that are made up of​  JavaScript : find an object in array based on object's property (and learn about the "find" function) Published on March 20, 2017 March 20, 2017 • 304 Likes • 48 Comments Report this post

OpenGL Object - OpenGL Wiki, All functions of this type have the same signature: When an object is deleted, if the object is bound to the current context (and note this For GLuint-based objects, the object name alone is not enough to identify the object,  If these objects contain additional information and code that you want to access, you can reach it through row objects. In the following code example, users can select multiple rows and click a button to send an invoice to each of the corresponding customers. To access row-bound objects. Use the DataGridViewRow.DataBoundItem property.

Late binding, Late binding, dynamic binding, or dynamic linkage is a computer programming mechanism in which the method being called upon an object or the function being called with arguments is looked up by name at runtime. With early binding, or static binding, in an object-oriented language, the Some COM-based languages such as Visual Basic 6 have syntactical  based on that, i stored the total value in an unbound field. i dont know how to assign the value from the unbound field to a bound field , Total, in the main form. Hi there! In subform's footer put an unbount control named SumProductCost. It's source property should be: =Sum(ProductCost)If I understood correctly you allready came this far.

this, Note: You can always easily get the global object using the global when o.f() is invoked, inside the function this is bound to the o object. Get Blender X,Y,Z and Bounding Box with script. You can get the bounding box corners Object.bound_box in object-space and Making statements based on opinion

Comments
  • Is <button (click)="myEvent()">My Button</button> inside your *ngFor loop?
  • @RukshanDangalla No. It's outside of the table as I've shown in my updated question.
  • @RukshanDangalla If the solution is to place my button inside *ngFor loop, I will change my code. Just please show me how should I do this?
  • Thanks. What is the const type? Why shouldn't it be of type my interface?
  • const is a keyword like var and let. It just signifies that this variable should not be written to again. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
  • And then how should I get the name from const item? Since my intellisence is not working after it! this is not working name:item.name,
  • If you add in a check to make sure the item was found, you should get rid of any issues. See update above.
  • If you added that check in, it was letting the typescript compiler know that any code that gets past it will have an item that is not undefined, which would allow you to then safely access the properties. So instead of the item being seen as type MyInterfaceType | undefined it sees it as just MyInterfaceType (after that if block of code)
  • Thanks. It is fine for let name = this.collection.find(t=> t.id == this.temp.id) but when I type name it doesn't show anything.
  • I can't access the object's properties after find method!
  • You should be able to use name ,just add a console.log(name) and see
  • Thanks. Can you please tell me, can I send the whole item (let item = this.collection.find(t=> t.id == this.temp.id)) to my WEB API as parameter? How should I pass a parameter of type MyInterface and get in server as equivalent model??