.netwpfxamlpathbinding

Confused about binding path and indexers


This is an example from .NET Documentation Binding Path Syntax: "Indexers and sub properties can be mixed in a Path clause; for example, Path=ShoppingCart.ShippingInfo[MailingAddress,Street]". Can someone explain to me where the properties MailingAddress and Street are defined.


Solution

  • You are interested in the example at this link: https://learn.microsoft.com/en-us/dotnet/api/system.windows.data.binding.path?view=windowsdesktop-9.0#remarks

    This example assumes that:

    1. the binding source-object has a "ShoppingCart" property.
    2. the object that is set in the "ShoppingCart" property has a "ShippingInfo" property. The "ShippingInfo" property is already a "subproperty" of the source-object.
    3. the object that is set in the "ShippingInfo" property has a two-dimensional string indexer. "MailingAddress" and "Street" are not properties, but values ​​for the indexer in the "ShippingInfo" property. Equivalent to writing var result = source.ShoppingCart.ShippingInfo["MailingAddress", "Street"]; in C#.