Mapper Key seems to be arbitrary

Jeff Pfahl 91 Reputation points
2022-06-16T17:46:57.55+00:00

When coding a mapping the key used does not seem to matter. Is there a case where the value matters. PickerBase can be any string and it still works.

    PickerHandler.Mapper.AppendToMapping("PickerBase", (handler, view) =>  
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,177 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rob Caplan - MSFT 5,437 Reputation points Microsoft Employee
    2022-06-17T01:49:27.7+00:00

    Correct. In general it's arbitrary - you can set it to anything that makes sense for your application. The name only matters if you're trying to modify a specific known mapping that you or somebody else will try to query for later.

    See Customize a Control with a Mapper

    A string-based key. When modifying one of the mappings provided by .NET MAUI, the key used by .NET MAUI must be specified. The key values used by .NET MAUI control mappings are based on interface and property names, for example nameof(IEntry.IsPassword). The interfaces, and their properties, that abstract each cross-platform control can be found here. Otherwise, this key can be an arbitrary value that doesn't have to correspond to the name of a property exposed by a type. For example, MyCustomization can be specified as a key, with any native control modification being performed as the customization.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful