4
votes

I've run across an annoying error in my Windows Phone 8.1 Runtime app. The error occurs where I defined my CommandBar on my page. That bar has been there almost since the creation of the app, but now the designer decided to make it an error. It reports the error as "Value does not fall within the expected range". Here is the code:

<Page.BottomAppBar>
    <!-- ERROR STARTS HERE --><CommandBar x:Name="ButtonBar" Background="{StaticResource StrikeDistanceThemeBrush}" Foreground="{StaticResource StrikeDistanceForegroundBrush}" BorderBrush="White">
        <CommandBar.SecondaryCommands>
            <AppBarButton x:Name="SettingsButton" Label="settings" Click="SettingsButton_Click"/>
            <AppBarButton x:Name="AboutButton" Label="about" Click="AboutButton_Click"/>
            <AppBarButton x:Name="AppsButton" Label="more apps"/>
            <AppBarButton x:Name="RateButton" Label="rate+review"/>
        </CommandBar.SecondaryCommands>
        <AppBarButton x:Name="CalculateButton" Label="calculate" Click="CalculateButton_Click" Icon="Calculator"/>
        <AppBarButton x:Name="ClearAllButton" Icon="Clear" Label="clear all" Click="ClearAllButton_Click"/>
        <AppBarButton x:Name="HelpButton" Icon="Help" Label="help"/>
    </CommandBar><!-- ERROR ENDS HERE -->
</Page.BottomAppBar>

Also, the CommandBar does appear while debugging the app, except elements that typically get nudged up (such as my AdDuplex control) don't get moved. So far, these things haven't resolved the problem:

  • Visual Studio restart
  • Computer restart
  • Creating a new CommandBar

Thanks for your help!

1
It could be a number of reasons. I would recreate the command bar from scratch, slowly adding each button one at a time until you can narrow down what exactly is causing the error. - Decade Moon
I have, it starts immediately after <CommandBar> .. </CommandBar>. - Greg Whatley
Ok, so you're saying that all that is required to reproduce the error is to have exactly this XAML only: <Page.BottomAppBar><CommandBar></CommandBar></Page.BottomAppBar>? - Decade Moon
You're exactly right. - Greg Whatley
That's really weird. I've had similar cryptic XAML designer errors in the past but I don't remember what solved them. Does the designer not show at all, except for an error message? Is there a stack trace? Have you looked here? Try deleting *.suo, *.settings and other files that are recreatable by VS, then restart VS (backup solution first). - Decade Moon

1 Answers

0
votes

Dunno if this will help you or if you've already tried, but you can delete the Visual Studio shadow cache. I use this trick whenever I've tried everything else with no success.

The shadow cache is located here:

%LOCALAPPDATA%\Microsoft\VisualStudio\12.0[this number will change depending on your Visual Studio version]\Designer\ShadowCache

Close Visual Studio, delete everything from this folder then restart Visual Studio. I created a handy little batch file that I can execute to save time.

Hope this helps.