CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
384 stars 89 forks source link

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

Open Katastroowl opened 1 year ago

Katastroowl commented 1 year ago

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: https://github.com/CommunityToolkit/Microsoft.Toolkit.Win32/issues/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:

Windows 10 Build Number:

Device form factor:

Visual Studio

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.

ghost commented 1 year ago

Hello Katastroowl, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback šŸ™Œ

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 1 year ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.