Skip to content

Failed to assign to property with VisualEx properties with ru-Ru locale #1685

@RomanGL

Description

@RomanGL

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Sample app request
[ ] Documentation issue or request
[ ] Question of Support request 

Current behavior

App crashes with "XamlParseException: Failed to assign to property "Microsoft.Toolkit.Uwp.UI.VisualEx.Scale" (and other VisualEx extensions) if in the Package.appxmanifest the default language parameter has "ru-RU" value.

u0qol53of6i 1

default

The problem lies in converting the string to a float using the float.Parse() method, because in russian locale the method accepts "0,9" (not "0.9").

Example, you need to use float.Parse("0.9", CultureInfo.InvariantCulture) for solve this problem.
A similar problem may occur in other areas of the library, if you are using a string conversion to number without InvariantCulture.

Expected behavior

VisualEx should work without exceptions.

Minimal reproduction of the problem with instructions

  1. Create blank app (e.g name App1) with default language "ru-RU" in Package.appxmanifest.
  2. Use UwpCommunityToolkit Nuget package.
  3. Put this code to MainPage.xaml:
<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:extensions="using:Microsoft.Toolkit.Uwp.UI.Extensions"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Border x:Name="Root"
                Background="DarkRed"
                extensions:VisualEx.Scale="0.5,0.5,0.5"/>
    </Grid>
</Page>
  1. Build and debug

Environment

Nuget Package(s): 2.1.0

Package Version(s): 2.1.0 (and latest preview 2.2.0)

Windows 10 Build Number:
- [ ] Anniversary Update (14393) 
- [ ] Creators Update (15063)
- [x] Fall Creators Update (16299)

App min and target version:
- [x] Anniversary Update (14393) 
- [ ] Creators Update (15063)
- [x] Fall Creators Update (16299)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x] Desktop
- [x] Mobile
- [?] Xbox
- [?] Surface Hub
- [?] IoT

Visual Studio 
- [ ] 2017 15.3
- [x] 2017 15.4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions