Using MessageBinder.SpecialValues in Windows 8 app not working?

孤街醉人 提交于 2019-12-04 16:50:20

I found your issue: Problem lies in CM source on this line:

else if (MessageBinder.SpecialValues.ContainsKey(parameterText.ToLower()) || char.IsNumber(parameterText[0]))

Not sure if it's considered a problem with the source - CM treats all SpecialValues keys as-is, but converts any specified action message special parameter strings to lowercase before comparing to the keys in the SpecialValues dictionary

The solution is to just add your SpecialValues parameter key as lowercase!

protected override void Configure()
{
    container = new WinRTContainer();
    container.RegisterWinRTServices();

    MessageBinder.SpecialValues.Add("$pointerpercentage", ctx =>
    {
        return 1.0f;
    });
}

I've seen you've posted this on CM codeplex site too, I've answered there - in my opinion this should be done on both the key in the dict and the key in your action message params to prevent this from happening. (It could be done when the SpecialValues.Add method is called to minimise code impact) - but that's something for CM devs to look at

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!