2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2013-05-07 18:12:25 +02:00
|
|
|
|
// Copyright © Clemens Fischer 2012-2013
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2012-12-06 23:28:12 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Container class for an item in a MapItemsControl.
|
|
|
|
|
|
/// </summary>
|
2012-11-22 21:42:29 +01:00
|
|
|
|
[TemplateVisualState(Name = "NotCurrent", GroupName = "CurrentStates")]
|
|
|
|
|
|
[TemplateVisualState(Name = "Current", GroupName = "CurrentStates")]
|
2012-12-06 23:28:12 +01:00
|
|
|
|
public class MapItem : ListBoxItem
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty IsCurrentProperty = MapItemsControl.IsCurrentProperty.AddOwner(
|
2013-04-12 19:59:16 +02:00
|
|
|
|
typeof(MapItem), new PropertyMetadata((o, e) => ((MapItem)o).IsCurrentPropertyChanged((bool)e.NewValue)));
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
static MapItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(
|
|
|
|
|
|
typeof(MapItem), new FrameworkPropertyMetadata(typeof(MapItem)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-26 19:17:12 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets a value that indicates if the MapItem is the CurrentItem of the containing items collection.
|
|
|
|
|
|
/// </summary>
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public bool IsCurrent
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (bool)GetValue(IsCurrentProperty); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void IsCurrentPropertyChanged(bool isCurrent)
|
|
|
|
|
|
{
|
|
|
|
|
|
var zIndex = Panel.GetZIndex(this);
|
|
|
|
|
|
|
|
|
|
|
|
if (isCurrent)
|
|
|
|
|
|
{
|
|
|
|
|
|
Panel.SetZIndex(this, zIndex | 0x40000000);
|
|
|
|
|
|
VisualStateManager.GoToState(this, "Current", true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Panel.SetZIndex(this, zIndex & ~0x40000000);
|
|
|
|
|
|
VisualStateManager.GoToState(this, "NotCurrent", true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|