[英]How can I specify the sort order of Enum values in the control manifest of a PCF component?
Let's assume having the following size
property of type Enum
in the ControlManifest.Input.xml
of a PCF component (Microsoft Power Apps component framework):假设在 PCF 组件(Microsoft Power Apps 组件框架)的
ControlManifest.Input.xml
中具有以下Enum
类型的size
属性:
<property name="size" display-name-key="size" of-type="Enum" usage="input" default-value="48">
<value name="10">10</value>
<value name="36">36</value>
<value name="100">100</value>
</property>
When used in a canvas App, the order of the values in the combobox for selecting the value of the property seems to be always in alphabetic order:在 canvas App 中使用时,combobox 中用于选择属性值的值的顺序似乎总是按字母顺序排列:
10
100
36
Is there any way to declare a different order?有什么办法可以声明不同的订单吗?
The documentation doesn't mention the value tag at all: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/property该文档根本没有提及价值标签: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/property
The best way I found so far is to pad the name with zeros:到目前为止我发现的最好方法是用零填充名称:
<property name="size" display-name-key="size" of-type="Enum" usage="input" default-value="48">
<value name="010">10</value>
<value name="036">36</value>
<value name="100">100</value>
</property>
This will let the values appear in the correct order:这将使值以正确的顺序出现:
10
36
100
I can even give them a more specific display name while keeping the correct order:我什至可以给他们一个更具体的显示名称,同时保持正确的顺序:
<property name="size" display-name-key="size" of-type="Enum" usage="input" default-value="48">
<value name="010" display-name-key="10px">10</value>
<value name="036" display-name-key="36px">36</value>
<value name="100" display-name-key="100px">100</value>
</property>
The only draw-back is that, as you can see on the advanced property editing tab, the selected value is stored with leading zeros:唯一的缺点是,正如您在高级属性编辑选项卡上看到的那样,所选值以前导零存储:
'NAMESPACE.ComponentName.PropertyName'.'010'
'NAMESPACE.ComponentName.PropertyName'.'036'
'NAMESPACE.ComponentName.PropertyName'.'100'
It might be a matter of personal taste that I don't like this representation of the values.我不喜欢这种价值观的表达方式,这可能是个人品味的问题。 So far it I can't find any draw-back caused by the leading zeros, it just doesn't feel right for my developers heart.
到目前为止,我找不到任何由前导零引起的缺点,它只是不适合我的开发人员的心。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.