WPF methods for obtaining entry controls based on data items-itemcontainergenerator

Source: Internet
Author: User

One. Method:

Containerfromindex: Returns the container for the item at the specified index in the itemcollection.

Containerfromitem: Returns the container (Comboxitem, etc.) that corresponds to the item being developed.

Equals (object): Determines whether the developed object is equal to the current object.

Finalize: Allows an object to attempt to free resources and attempt other cleanup operations before garbage collection is reclaimed against object.

Generatorpositionfromindex: Gets the location at which the item was generated at the specified index.

GetHashCode: Serves as a hash function for a particular type.

GetType: Gets the type of the current instance.

Indexfromcontainer: Gets the index of the item that has the specified generated container.

Indexfromgeneratorposition: Returns the index mapped to the specified gereratorposition.

Itemfromcontainer: Returns the corresponding item generated by the specified container.

Two. Events

Itemschanged: Occurs when an item within the collection has changed.

Three. Note

Notesthe ItemContainerGenerator class maintains an association between an item control and its item container. If a control has an associated itemcontainergenerator, it can be retrieved through the properties of the control.

You can useItemContainerGenerator Retrieves the item or retrieves the container by specifying a data item, based on the index of the item. For example, if you have a combox that has data boundand you want to get a comboxitem based on its index, you can use the Containerfromindex method. If you want to retrieve data items, you can use the Itemfromcontainer method.

Four. Example:

C#:

Public MyTest () {    InitializeComponent ();    String[] mycollection= New string[]{"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};   



Conmboxitem item = (Comboxitem)
  

}

Xaml:

<stackpanel x:name= "LayoutRoot" background= "white" >    <combox x:name= "Mycombox" width= "$" itemssource= "{Binding}" margin= "5"/>    <button content= "Add Child to Item 4" width= "" click= "Button_Click"/></ Stackpanel>

WPF methods for obtaining entry controls based on data items-itemcontainergenerator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.