Discussion Board

Results 1 to 1 of 1
  1. #1
    Registered User
    Join Date
    Aug 2013
    Denver, CO

    Setting DefaultStyleKey results in "Value does not fall within the expected range"

    I'm configuring a base page for my mobile application to have a couple additional boolean dependency properties to activate or deactivate some universal application bar menu items. Even though I'm registering these dependency properties with metadata about their default values, it doesn't seem that the change handler for the value is ever called.

    public class MyPageBase : PhoneApplicationPage
        public MyBasePage() {
            DefaultStyleKey = typeof(MyPageBase);
        public static readonly DependencyProperty ShowSettingsMenuItemProperty =
            new PropertyMetadata(true, ShowSettingsMenuItemChanged));
        public static readonly DependencyProperty ShowLogoutMenuItemProperty =
            new PropertyMetadata(true, ShowLogoutMenuItemChanged));
    I assumed then that I need to create a default "theme" for the page that sets these two properties to their values. I created a Themes folder and a Generic.xaml file inside with its build action set to Page. I then defined a very simple style targeting the page type that set the two properties to the default values in their metadata.

    HTML Code:
        <Style TargetType="view:MyPageBase">
            <Setter Property="ShowLogoutMenuItem" Value="True" />
            <Setter Property="ShowSettingsMenuItem" Value="True" />
    However, when the first line in the base page's constructor is hit, the following exception is raised:

    System.ArgumentException: Value does not fall within the expected range.
    I've inspected the compiled library in ILSpy, and the Resources folder does contain a g.resources folder with all of the XAML files from the project, including one for themes/generic.xaml. What needs to be done to correctly initialize the default value of these dependency properties?
    Last edited by antix710; 2013-08-18 at 16:48.

Similar Threads

  1. Replies: 6
    Last Post: 2011-04-14, 12:56
  2. SyncML-DS mandatory "OK" status for results?
    By bontea_g in forum OMA DM/DS/CP
    Replies: 1
    Last Post: 2009-03-17, 12:33
  3. "String index out of range: -1"
    By hongnhun in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2008-09-27, 12:22
  4. Replies: 0
    Last Post: 2007-07-24, 21:49
  5. How to modify the control pane label "OK" and "Cancel" of Text Setting item
    By misfit.physics in forum Symbian User Interface
    Replies: 5
    Last Post: 2007-02-27, 06:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts