diff --git a/MBTiles/Avalonia/MBTiles.Avalonia.csproj b/MBTiles/Avalonia/MBTiles.Avalonia.csproj
index 990c02f4..3bac3f5d 100644
--- a/MBTiles/Avalonia/MBTiles.Avalonia.csproj
+++ b/MBTiles/Avalonia/MBTiles.Avalonia.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/MapControl/Avalonia/MapControl.Avalonia.csproj b/MapControl/Avalonia/MapControl.Avalonia.csproj
index c1ff0d2c..a664015f 100644
--- a/MapControl/Avalonia/MapControl.Avalonia.csproj
+++ b/MapControl/Avalonia/MapControl.Avalonia.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/MapControl/Avalonia/MapItem.Avalonia.cs b/MapControl/Avalonia/MapItem.Avalonia.cs
index f30774cc..6c28efb8 100644
--- a/MapControl/Avalonia/MapItem.Avalonia.cs
+++ b/MapControl/Avalonia/MapItem.Avalonia.cs
@@ -10,7 +10,7 @@ namespace MapControl
if (e.Pointer.Type != PointerType.Mouse &&
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
{
- mapItemsControl.UpdateSelection(this, e);
+ mapItemsControl.UpdateSelectionFromEvent(this, e);
}
e.Handled = true;
@@ -22,7 +22,7 @@ namespace MapControl
e.InitialPressMouseButton == MouseButton.Left &&
ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
{
- mapItemsControl.UpdateSelection(this, e);
+ mapItemsControl.UpdateSelectionFromEvent(this, e);
}
e.Handled = true;
diff --git a/MapControl/Avalonia/MapItemsControl.Avalonia.cs b/MapControl/Avalonia/MapItemsControl.Avalonia.cs
index 2fd4e8b6..83dd1873 100644
--- a/MapControl/Avalonia/MapItemsControl.Avalonia.cs
+++ b/MapControl/Avalonia/MapItemsControl.Avalonia.cs
@@ -1,7 +1,9 @@
-using Avalonia.Controls;
+using Avalonia;
+using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Templates;
using Avalonia.Input;
+using Avalonia.Interactivity;
using Avalonia.Media;
namespace MapControl
@@ -52,17 +54,22 @@ namespace MapControl
ClearContainer((MapItem)container);
}
- internal void UpdateSelection(MapItem mapItem, PointerEventArgs e)
+ protected override bool ShouldTriggerSelection(Visual selectable, PointerEventArgs eventArgs)
{
- if (SelectionMode != SelectionMode.Single &&
+ return true;
+ }
+
+ public override bool UpdateSelectionFromEvent(UIElement container, RoutedEventArgs eventArgs)
+ {
+ if (SelectionMode == SelectionMode.Multiple &&
+ eventArgs is PointerEventArgs e &&
e.KeyModifiers.HasFlag(KeyModifiers.Shift))
{
- SelectItemsInRange(mapItem);
- }
- else
- {
- UpdateSelection(mapItem, true, false, e.KeyModifiers.HasFlag(KeyModifiers.Control));
+ SelectItemsInRange((MapItem)container);
+ return true;
}
+
+ return base.UpdateSelectionFromEvent(container, eventArgs);
}
}
}
diff --git a/MapProjections/Avalonia/MapProjections.Avalonia.csproj b/MapProjections/Avalonia/MapProjections.Avalonia.csproj
index b9dbf1fb..7d910564 100644
--- a/MapProjections/Avalonia/MapProjections.Avalonia.csproj
+++ b/MapProjections/Avalonia/MapProjections.Avalonia.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/MapUiTools/Avalonia/MapLayerInfo.xaml b/MapUiTools/Avalonia/MapLayerInfo.xaml
index 651945d8..636e59ec 100644
--- a/MapUiTools/Avalonia/MapLayerInfo.xaml
+++ b/MapUiTools/Avalonia/MapLayerInfo.xaml
@@ -13,8 +13,6 @@
-
-
@@ -37,6 +35,8 @@
-
+
diff --git a/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj b/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj
index c0f7f5a0..79b60bac 100644
--- a/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj
+++ b/MapUiTools/Avalonia/MapUiTools.Avalonia.csproj
@@ -4,16 +4,13 @@
AVALONIA
MapControl.UiTools
XAML Map Control UI Tools Library for Avalonia UI
+ false
-
-
-
-
MSBuild:Compile
@@ -25,7 +22,6 @@
-
-
+
diff --git a/MapUiTools/Shared/HyperlinkText.cs b/MapUiTools/Shared/HyperlinkText.cs
index ba889614..8dedbb27 100644
--- a/MapUiTools/Shared/HyperlinkText.cs
+++ b/MapUiTools/Shared/HyperlinkText.cs
@@ -14,6 +14,12 @@ using Microsoft.UI.Xaml.Documents;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
+#elif AVALONIA
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.Documents;
+using Avalonia.Media;
+using DependencyProperty = Avalonia.AvaloniaProperty;
#endif
namespace MapControl.UiTools
@@ -38,14 +44,39 @@ namespace MapControl.UiTools
match.Groups.Count == 3 &&
Uri.TryCreate(match.Groups[2].Value, UriKind.Absolute, out Uri uri))
{
- inlines.Add(new Run { Text = text.Substring(0, match.Index) });
+ inlines.Add(new Run
+ {
+ Text = text.Substring(0, match.Index),
+#if WPF || AVALONIA
+ BaselineAlignment = BaselineAlignment.Center
+#endif
+ });
+
text = text.Substring(match.Index + match.Length);
- var link = new Hyperlink { NavigateUri = uri };
- link.Inlines.Add(new Run { Text = match.Groups[1].Value });
-#if WPF
- link.ToolTip = uri.ToString();
+ var hyperlinkText = match.Groups[1].Value;
+#if AVALONIA
+ var button = new HyperlinkButton
+ {
+ Content = hyperlinkText,
+ NavigateUri = uri,
+ Padding = new Thickness(0),
+ Margin = new Thickness(0)
+ };
+ var link = new InlineUIContainer
+ {
+ Child = button,
+ BaselineAlignment = BaselineAlignment.Center
+ };
+#else
+ var run = new Run { Text = hyperlinkText };
+ var link = new Hyperlink { NavigateUri = uri };
+ link.Inlines.Add(run);
+#if WPF
+ run.BaselineAlignment = BaselineAlignment.Center;
+ link.BaselineAlignment = BaselineAlignment.Center;
+ link.ToolTip = uri.ToString();
link.RequestNavigate += (_, e) =>
{
try
@@ -57,6 +88,7 @@ namespace MapControl.UiTools
Debug.WriteLine($"{e.Uri}: {ex}");
}
};
+#endif
#endif
inlines.Add(link);
}
@@ -70,41 +102,29 @@ namespace MapControl.UiTools
return inlines;
}
- public static readonly DependencyProperty InlinesSourceProperty = DependencyProperty.RegisterAttached(
- "InlinesSource", typeof(string), typeof(HyperlinkText), new PropertyMetadata(null, InlinesSourcePropertyChanged));
+ public static readonly DependencyProperty InlinesSourceProperty =
+ DependencyPropertyHelper.RegisterAttached("InlinesSource", typeof(HyperlinkText), null,
+ (element, oldValue, newValue) =>
+ {
+ if (element is TextBlock textBlock)
+ {
+ textBlock.Inlines.Clear();
- public static string GetInlinesSource(DependencyObject element)
+ foreach (var inline in TextToInlines(newValue))
+ {
+ textBlock.Inlines.Add(inline);
+ }
+ }
+ });
+
+ public static string GetInlinesSource(TextBlock element)
{
return (string)element.GetValue(InlinesSourceProperty);
}
- public static void SetInlinesSource(DependencyObject element, string value)
+ public static void SetInlinesSource(TextBlock element, string value)
{
element.SetValue(InlinesSourceProperty, value);
}
-
- private static void InlinesSourcePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
- {
- InlineCollection inlines = null;
-
- if (obj is TextBlock block)
- {
- inlines = block.Inlines;
- }
- else if (obj is Paragraph paragraph)
- {
- inlines = paragraph.Inlines;
- }
-
- if (inlines != null)
- {
- inlines.Clear();
-
- foreach (var inline in TextToInlines((string)e.NewValue))
- {
- inlines.Add(inline);
- }
- }
- }
}
}
diff --git a/MapUiTools/Shared/MapLayerInfo.xaml.cs b/MapUiTools/Shared/MapLayerInfo.xaml.cs
index b81c2bf3..84ef589e 100644
--- a/MapUiTools/Shared/MapLayerInfo.xaml.cs
+++ b/MapUiTools/Shared/MapLayerInfo.xaml.cs
@@ -7,7 +7,7 @@ using Windows.UI.Xaml.Controls;
#elif WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
-#else
+#elif AVALONIA
using Avalonia.Controls;
using DependencyProperty = Avalonia.AvaloniaProperty;
using FrameworkElement = Avalonia.Controls.Control;
diff --git a/MapUiTools/Shared/MapLayerMenuItem.cs b/MapUiTools/Shared/MapLayerMenuItem.cs
index f2b53063..d458ed7f 100644
--- a/MapUiTools/Shared/MapLayerMenuItem.cs
+++ b/MapUiTools/Shared/MapLayerMenuItem.cs
@@ -10,7 +10,7 @@ using Windows.UI.Xaml.Markup;
#elif WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Markup;
-#else
+#elif AVALONIA
using Avalonia.Metadata;
using FrameworkElement = Avalonia.Controls.Control;
#endif
diff --git a/MapUiTools/Shared/MapProjectionMenuItem.cs b/MapUiTools/Shared/MapProjectionMenuItem.cs
index 6648cd9e..121d3fab 100644
--- a/MapUiTools/Shared/MapProjectionMenuItem.cs
+++ b/MapUiTools/Shared/MapProjectionMenuItem.cs
@@ -8,7 +8,7 @@ using System.Windows.Markup;
using Windows.UI.Xaml.Markup;
#elif WINUI
using Microsoft.UI.Xaml.Markup;
-#else
+#elif AVALONIA
using Avalonia.Metadata;
#endif
diff --git a/MapUiTools/Shared/MenuButton.cs b/MapUiTools/Shared/MenuButton.cs
index 5fecf16b..fe777246 100644
--- a/MapUiTools/Shared/MenuButton.cs
+++ b/MapUiTools/Shared/MenuButton.cs
@@ -9,7 +9,7 @@ using Windows.UI.Xaml.Controls;
#elif WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
-#else
+#elif AVALONIA
using Avalonia.Controls;
using DependencyProperty = Avalonia.AvaloniaProperty;
#endif
diff --git a/SampleApps/AvaloniaApp/AvaloniaApp.csproj b/SampleApps/AvaloniaApp/AvaloniaApp.csproj
index 91cbdfa0..e0a57153 100644
--- a/SampleApps/AvaloniaApp/AvaloniaApp.csproj
+++ b/SampleApps/AvaloniaApp/AvaloniaApp.csproj
@@ -5,6 +5,7 @@
AVALONIA
SampleApplication
XAML Map Control Avalonia Sample Application
+ false
@@ -28,11 +29,12 @@
-
-
-
-
-
+
+
+
+
+
+