2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2015-01-20 17:52:02 +01:00
|
|
|
|
// © 2015 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Windows;
|
2012-11-23 23:00:50 +01:00
|
|
|
|
using System.Windows.Controls;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2013-08-17 08:41:11 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Manages a collection of selectable items on a Map. Uses MapItem as item container class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class MapItemsControl : ListBox
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
static MapItemsControl()
|
|
|
|
|
|
{
|
2013-08-17 08:41:11 +02:00
|
|
|
|
DefaultStyleKeyProperty.OverrideMetadata(
|
2012-11-22 21:42:29 +01:00
|
|
|
|
typeof(MapItemsControl), new FrameworkPropertyMetadata(typeof(MapItemsControl)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-23 16:16:09 +01:00
|
|
|
|
public MapItemsControl()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2013-08-17 08:41:11 +02:00
|
|
|
|
Items.CurrentChanging += CurrentItemChanging;
|
|
|
|
|
|
Items.CurrentChanged += CurrentItemChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override DependencyObject GetContainerForItemOverride()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new MapItem();
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-06-11 23:03:13 +02:00
|
|
|
|
protected override bool IsItemItsOwnContainerOverride(object item)
|
|
|
|
|
|
{
|
|
|
|
|
|
return item is MapItem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-08-17 08:41:11 +02:00
|
|
|
|
private void CurrentItemChanging(object sender, CurrentChangingEventArgs e)
|
2012-11-23 23:00:50 +01:00
|
|
|
|
{
|
2013-08-17 08:41:11 +02:00
|
|
|
|
var container = ItemContainerGenerator.ContainerFromItem(Items.CurrentItem) as UIElement;
|
2012-11-23 23:00:50 +01:00
|
|
|
|
|
2013-08-17 08:41:11 +02:00
|
|
|
|
if (container != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var zIndex = Panel.GetZIndex(container);
|
|
|
|
|
|
Panel.SetZIndex(container, zIndex & ~0x40000000);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CurrentItemChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var container = ItemContainerGenerator.ContainerFromItem(Items.CurrentItem) as UIElement;
|
|
|
|
|
|
|
|
|
|
|
|
if (container != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var zIndex = Panel.GetZIndex(container);
|
|
|
|
|
|
Panel.SetZIndex(container, zIndex | 0x40000000);
|
|
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-08-17 08:41:11 +02:00
|
|
|
|
}
|