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

Fix a bug where the collections MapElements cannot be manipulated fro…#113

Merged
azchohfi merged 5 commits intomasterfrom
FixMapElements
May 2, 2019
Merged

Fix a bug where the collections MapElements cannot be manipulated fro…#113
azchohfi merged 5 commits intomasterfrom
FixMapElements

Conversation

@ocalvo
Copy link
Contributor

@ocalvo ocalvo commented May 1, 2019

This change fixes an issue with WPF and WinForms MapElements property.
In WPF the property is initialized as null and in WinForms any change to the property is lost.

Issue: #

112[https://github.com//issues/112]
62[https://github.com//issues/62]

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

When adding items to the Map.MapElements collection they will not appear on the map, code works in UWP but not in WinForms.

private void Map_MapTapped(object sender, MapInputEventArgs e)
{
	var pushpin = new MapIcon
	{
		Location = e.Location,
		Title = "Here's something interesting!",
		CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible,
		NormalizedAnchorPoint = new Point(0.5, 1)
	};

	Map.MapElements.Add(pushpin);

	Debug.WriteLine(Map.MapElements.Count);
}

Expected behavior
I would expect the map element to be added...

What is the new behavior?

After calling Map.MapElements.Add(pushpin), the element is added and it is shown on the Map control.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

We are removing the metadata property MapElementsProperty in the WPF control as this is no longer required.

Other information

@ocalvo ocalvo requested a review from azchohfi May 1, 2019 21:15
Copy link

@Austin-Lamb Austin-Lamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main thing I think should be done before merging this is getting the Layers property to work too, since that was reported as having the same bug.

/// <summary>
/// Gets <see cref="windows.UI.Xaml.Controls.Maps.MapControl.MapElementsProperty"/>
/// </summary>
public static DependencyProperty MapElementsProperty { get; } = DependencyProperty.Register(nameof(MapElements), typeof(System.Collections.Generic.IList<MapElement>), typeof(MapControl));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the removal of Dependency Properties, I assume that means data binding on those will be not possible. Am I missing something?

@azchohfi azchohfi dismissed michael-hawker’s stale review May 2, 2019 00:56

Synced offline.

@azchohfi azchohfi merged commit 7252b96 into master May 2, 2019
@azchohfi azchohfi deleted the FixMapElements branch May 2, 2019 00:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants