1

I'm making an app for Windows 8.1 using C# and XAML. All the strings are located in a resource file called Resources.resw located in the folder en-GB.

I'm loading the string like this using XAML:

             <AppBarButton Icon="Document"
                           x:Uid="AddFiles" 
                           Label="Add files"  
                           Click="btnAddFiles_Click"/>

and using C# like this (for MessageDialogs):

        var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
        var text = loader.GetString(@"Error") + exceptionRoutedEventArgs.ErrorMessage +                       
                    "\r\n\r\n" + loader.GetString(@"Error_FileTypeNotSupported")
        var messageDialog = new MessageDialog(text);
        messageDialog.ShowAsync();

where exceptionRoutedEventArgs is a ExceptionRoutedEventArgs object.

When I run my app, everything works perfectly.

The next step in developing my app is adding multi-language support. I enabled the Multilingual App Toolkit and I added German. The folder MultilingualResources was created and the .xlf file for the German translation was added. I added German as my main language on the PC and when I run my app, the splashcreen was displayed and the code was running, but then suddenly, when my main page should have been displayed, a black screen appears. I tried to run it again, to rebuild project , but the same issue all the time. If I removed the German translation file (the .xlf), the issue was solved, but I needed the translations, so I added the German translation file again and the issue was there again... It was actually only while I writing this thread that I realised the problem is actually that the Bottom App Bar of the app (which has a black background) covers the entire screen (but all the controls on the App Bar don't appear). Surprisingly, the Top App Bar of another page work perfectly fine. There isn't anything special at my bottom app bar : only some Grids, StackPanels and several App Bar Buttons like the ones shown in the first code sequence.

This is the Top App Bar

  <Page.TopAppBar>
     <CommandBar>

        <CommandBar.SecondaryCommands>

            <AppBarButton Label="Start" Icon="Play" Click="StartButton_OnClick"/>
            <AppBarButton Label="Stop" Icon="Stop" Click="StopButton_OnClick"/>

        </CommandBar.SecondaryCommands>

     </CommandBar>
 </Page.TopAppBar>

And this is the Bottom App Bar

<Page.BottomAppBar>
    <AppBar IsSticky="True"     
            Width="{Binding Path=MainPageSize.Width}"
            Height="{Binding Path=MainPageSize.Height, Converter={StaticResource  MultiplierConverter}, ConverterParameter='0.15'}" IsOpen="True">

        <userControls:MainPageBottomAppBar/>

    </AppBar>
</Page.BottomAppBar>

The variable MainPageSize has the dimensions of the page and the Width of the BottomAppBar is supposed to be equal with the Width of the Page while the Height to be 15 % of the Height of the Page. This works perfectly if the language resources are not activated. The problem apparently is that the Converter somehow doesn't work and makes the Height of the Bar equal to the one of the Page and somehow the content is hidden (the AppBarButtons). If I use Height=" 200" , than the AppBar no longer occupies the entire page, but the content is still hidden.

 public class MultiplierConverter : IValueConverter
   {
    public object Convert(object value, Type targetType, object parameter, string language)
    {
        var a = System.Convert.ToDouble(value);
        var b = System.Convert.ToDouble(parameter);

        return a*b;
    }

    public object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        throw new NotImplementedException();
    }
}

So could someone tell me how to solve the problem ?

L.E.: Ok, I discovered the problem. This is kinda funny actually. The English use " . " for decimals number so that the 0.15 will be interpreted as 0.15 when English is used, but will be interpreted as 15 when German is used because they use " , " for decimals. The problem is that I still don't know to solve the issue. Is the something like culture dependent parsing for double numbers ?

TheQuestioner
  • 427
  • 1
  • 7
  • 23

1 Answers1

0

Ok, so all I had to do was replace

        var b = System.Convert.ToDouble(parameter);

with

        var b = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);

Thanks for help anyway ! :)

TheQuestioner
  • 427
  • 1
  • 7
  • 23