locked
System.ArgumentException on UISettings.UIElementColor(UIElementType)

    Question

  • I am learning Windows Store App Programming with Programming Windows 6th edition.

    By release of Windows Phone 8.1, we can run WinRT apps in Windows Phone, so I tested codes as followings.

    Brush highlightBrush = new SolidColorBrush(new UISettings().UIElementColor(UIElementType.Highlight));

    It runs well on Windows 8.1 Update 1 x64, and builds well on Windows 8.1 Update 1 x64 and Windows Phone 8.1 Update 1, but it can't run on windows phone 8.1 update 1 both emulator and my Lumia 1020, with System.ArgumentException.

    The additional information about this error is "Values does not fall within the expected range".

    So I expanded the code and found the point that error occurs : UIElementColor(UIElementType.Highlight)

    I can't find the bug and understand why this phenomenon happens. Help me please.

    Sunday, September 21, 2014 7:00 AM

Answers

  • Hi bdh0404,

    Per my understanding, the issue might be related with UIElementType enumeration, here you use UIElementType.Hightlight which cause the error, could you try with UIElementType.TextHigh instead.

    I think the value from 0-12 only work with Windows Store App, value 1000-1012 are working with Windows Phone if you see the description of the members.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by bdh0404 Tuesday, September 23, 2014 1:01 PM
    Monday, September 22, 2014 8:22 AM
    Moderator

All replies

  • Hi bdh0404,

    Per my understanding, the issue might be related with UIElementType enumeration, here you use UIElementType.Hightlight which cause the error, could you try with UIElementType.TextHigh instead.

    I think the value from 0-12 only work with Windows Store App, value 1000-1012 are working with Windows Phone if you see the description of the members.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by bdh0404 Tuesday, September 23, 2014 1:01 PM
    Monday, September 22, 2014 8:22 AM
    Moderator
  • Thanks for your answer, and I am very sorry for replying late. I didn't have time to test the new code.

    Thank you.

    Tuesday, September 23, 2014 1:04 PM