mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-08 07:55:13 +00:00
UIElementExtension
This commit is contained in:
parent
f382c59d19
commit
d777516e35
1 changed files with 4 additions and 3 deletions
43
MapControl/Shared/UIElementExtension.cs
Normal file
43
MapControl/Shared/UIElementExtension.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#if AVALONIA
|
||||
global using UIElement = Avalonia.Controls.Control;
|
||||
global using FrameworkElement = Avalonia.Controls.Control;
|
||||
using Avalonia;
|
||||
using Avalonia.Media;
|
||||
#elif WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
#elif WINUI
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public static class UIElementExtension
|
||||
{
|
||||
public static void SetRenderTransform(this UIElement element, Transform transform, bool center = false)
|
||||
{
|
||||
element.RenderTransform = transform;
|
||||
#if AVALONIA
|
||||
element.RenderTransformOrigin = center ? RelativePoint.Center : RelativePoint.TopLeft;
|
||||
#else
|
||||
if (center)
|
||||
{
|
||||
element.RenderTransformOrigin = new Point(0.5, 0.5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void SetVisible(this UIElement element, bool visible)
|
||||
{
|
||||
#if AVALONIA
|
||||
element.IsVisible = visible;
|
||||
#else
|
||||
element.Visibility = visible ? Visibility.Visible : Visibility.Collapsed;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue