Code cleanup

This commit is contained in:
ClemensFischer 2026-01-06 07:54:45 +01:00
parent 03e0258f18
commit 497c415562
2 changed files with 15 additions and 18 deletions

View file

@ -238,23 +238,20 @@ namespace MapControl
element = (FrameworkElement)template.LoadContent();
}
#endif
if (element != null)
{
element.DataContext = layer;
}
element?.DataContext = layer;
return element;
}
#if UWP || WINUI
private static object TryFindResource(FrameworkElement element, object key)
{
return element.Resources.ContainsKey(key)
? element.Resources[key]
: element.Parent is FrameworkElement parent
? TryFindResource(parent, key)
: null;
}
private static object TryFindResource(FrameworkElement element, object key)
{
return element.Resources.ContainsKey(key)
? element.Resources[key]
: element.Parent is FrameworkElement parent
? TryFindResource(parent, key)
: null;
}
#endif
}
}

View file

@ -1,9 +1,4 @@
#if AVALONIA
global using UIElement = Avalonia.Controls.Control;
global using FrameworkElement = Avalonia.Controls.Control;
using Avalonia;
using Avalonia.Media;
#elif WPF
#if WPF
using System.Windows;
using System.Windows.Media;
#elif UWP
@ -12,6 +7,11 @@ using Windows.UI.Xaml.Media;
#elif WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
#elif AVALONIA
global using UIElement = Avalonia.Controls.Control;
global using FrameworkElement = Avalonia.Controls.Control;
using Avalonia;
using Avalonia.Media;
#endif
namespace MapControl