Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Namespaces Binding Error 1 and 5 when using MapControl wrapper #352

@Katastroowl

Description

@Katastroowl

Describe the bug

I believe that https://github.com/CommunityToolkit/Microsoft.Toolkit.Win32/blob/master/Microsoft.Toolkit.Wpf.UI.Controls/MapControl/MapControl.cs has wrong namespaces and that might be the reason why binding doesn't work??:
Example: Bind(nameof(Style), StyleProperty, windows.UI.Xaml.Controls.Maps.MapControl.StyleProperty);

The "w" from windows.UI... should be "W" capital.

I don't know if that has anything to do with the primal issue, but further I cannot trace it...

Toolkit version: 6.1.2

Steps to Reproduce

There are no steps to reproduce. Except of maybe: #205

Expected behavior

That this does not show up:
System.Windows.Data Error: 1 : Cannot create default converter to perform 'one-way' conversions between types 'Windows.UI.Xaml.Controls.Maps.MapStyle' and 'Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT.MapStyle'. Consider using Converter property of Binding. BindingExpression:Path=Style; DataItem='MapControl' (HashCode=53182860); target element is 'MapControl' (Name=''); target property is 'Style' (type 'MapStyle')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='Road' BindingExpression:Path=Style; DataItem='MapControl' (HashCode=53182860); target element is 'MapControl' (Name=''); target property is 'Style' (type 'MapStyle')

And that the MapControl actually changes its Style, because it doesn't.

Screenshots

Screenshot in Issue 205.

Environment

NuGet Package(s):

Package Version(s):

Project .NET Version:

  • [x ] .NET Framework (version: 4.8.2 )
  • .NET Core 3
  • .NET Core 3.1 Preview (version: )

Windows 10 Build Number:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • [x ] Build (build number: 19043.2130)

Device form factor:

  • [x ] Desktop
  • Xbox
  • Surface Hub
  • IoT

Visual Studio

  • 2017 (version: )
  • [x ] 2019 (version: 16.11.19 Pro)
  • 2019 Preview (version: )

Additional context

I tried to access Inner object via reflection, but also that did not change the Map Style, thou, it was shown for a Microsecond, but immediatelly turned to normal again.
Code here:

MapControl ActualMap = new MapControl();
ActualMap.Loaded += ActualMapLoaded;
ActualMap.MapServiceToken = MapToken;
ActualMap.Style = MapStyle.Aerial;
PropertyInfo propertyInfo = ActualMap.GetUwpInternalObject().GetType().GetProperty(nameof(ActualMap.Style), BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
if (propertyInfo != null)
{
Debug.WriteLine("PROPERTY FOUND: " + propertyInfo.Name);
propertyInfo.SetValue(ActualMap.GetUwpInternalObject(), Convert.ChangeType(Windows.UI.Xaml.Controls.Maps.MapStyle.Aerial, propertyInfo.PropertyType), null);
}
Debug.WriteLine("MAPSTYLE: " + ActualMap.Style.ToString());
Debug.WriteLine("INTERNAL OBJECT: " + ActualMap.GetUwpInternalObject());
//= Windows.UI.Xaml.Controls.Maps.MapControl
Debug.WriteLine("MAPSTYLE of INTERNAL: " + ((Windows.UI.Xaml.Controls.Maps.MapControl)ActualMap.GetUwpInternalObject()).Style.ToString());
Debug.WriteLine("LAYERS: " + ActualMap.Layers.Count());
MapGrid.Children.Add(ActualMap);

You can see on the results, that both objects/ properties accept the new value, but the Map still not show with changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions