How does the VS XAML designer know what it takes to automatically populate specific values?

<Button Name="MyButton" Content="Test" FontStyle="Italic" />

In the above definition of a XAML button, the property FontStyleis set to Italic. The designer can somehow fill out the list for me to choose when I hit the sign =. How is this achieved?

Before you answer, consider that the property FontStyle, accordingly, has a type FontStyle(which is a structure). This is not an enumeration that would be trivial for VS to list it at design time, since a valid list of selected options will be displayed? There is also a separate class FontStylesthat contains three static fields: Italic,, Normaland Oblique, which, as it turned out, are the three elements that VS provides in the drop-down list. Is there some kind of mapping going on behind the scenes between the FontStylestruct class and FontStylesbecause I looked in many places in both the object browser and the .NET Reflector and could not identify any of them.

Thank!!

I NEED TO KNOW! *

* Not really, but it would be nice :)

+3
source share
2 answers

The XAML language service uses the GetStandardValues ​​() type converter to determine what to show in the drop-down list for the type. This is the same as the property grid.

Unfortunately, the infrastructure type converter does not always implement GetStandardValues ​​(), so the developer will often provide internal replacements for many of these types. The property grid and XAMl language service use these internal replacements.

+1
source

I have no answer, but what is interesting is that there is an internal FontStyle enumeration. MS.Internal.Text.TextInterface.Font style, which is defined as

internal enum FontStyle
{
    Normal,
    Oblique,
    Italic
}

, intellisense.

0

Source: https://habr.com/ru/post/1741553/


All Articles