mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
MapLayer/MapLayerItemsSource
This commit is contained in:
parent
bb47829cd3
commit
21ac686843
5 changed files with 24 additions and 78 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
|
|
@ -54,14 +55,14 @@ namespace MapControl
|
|||
|
||||
private void MapLayerPropertyChanged(object oldLayer, object newLayer)
|
||||
{
|
||||
var firstChild = GetChildElement(0);
|
||||
var firstChild = Children.Cast<FrameworkElement>().FirstOrDefault();
|
||||
|
||||
if (oldLayer != null)
|
||||
{
|
||||
if (firstChild != null &&
|
||||
(firstChild == oldLayer as FrameworkElement || firstChild.DataContext == oldLayer))
|
||||
{
|
||||
RemoveChildElement(0);
|
||||
Children.RemoveAt(0);
|
||||
}
|
||||
|
||||
if (hasMapLayerBackground)
|
||||
|
|
@ -83,10 +84,10 @@ namespace MapControl
|
|||
if (firstChild == null ||
|
||||
firstChild != newLayer as FrameworkElement && firstChild.DataContext != newLayer)
|
||||
{
|
||||
InsertChildElement(0, GetMapLayer(newLayer));
|
||||
Children.Insert(0, GetMapLayer(newLayer));
|
||||
}
|
||||
|
||||
if (GetChildElement(0) is IMapLayer mapLayer)
|
||||
if (Children.Cast<FrameworkElement>().FirstOrDefault() is IMapLayer mapLayer)
|
||||
{
|
||||
if (mapLayer.MapBackground != null)
|
||||
{
|
||||
|
|
@ -168,17 +169,23 @@ namespace MapControl
|
|||
|
||||
private void AddMapLayers(List<FrameworkElement> mapLayers, int index)
|
||||
{
|
||||
InsertChildElements(index, mapLayers);
|
||||
|
||||
if (index == 0)
|
||||
foreach (var mapLayer in mapLayers)
|
||||
{
|
||||
MapLayer = mapLayers[0];
|
||||
Children.Insert(index, mapLayer);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
MapLayer = mapLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveMapLayers(IEnumerable items, int index)
|
||||
{
|
||||
RemoveChildElements(index, items.Cast<object>().Count());
|
||||
foreach (var _ in items)
|
||||
{
|
||||
Children.RemoveAt(index);
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#if WPF
|
||||
using System.Linq;
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
|
@ -172,7 +173,7 @@ namespace MapControl
|
|||
{
|
||||
availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
|
||||
|
||||
foreach (var element in ChildElements)
|
||||
foreach (var element in Children.Cast<FrameworkElement>())
|
||||
{
|
||||
element.Measure(availableSize);
|
||||
}
|
||||
|
|
@ -184,7 +185,7 @@ namespace MapControl
|
|||
{
|
||||
if (parentMap != null)
|
||||
{
|
||||
foreach (var element in ChildElements)
|
||||
foreach (var element in Children.Cast<FrameworkElement>())
|
||||
{
|
||||
ArrangeChildElement(element, finalSize);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue