2025-09-16 14:18:29 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
#if WPF
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
#elif UWP
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
#elif WINUI
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Microsoft.UI.Xaml.Data;
|
|
|
|
|
#else
|
|
|
|
|
using Avalonia.Data.Converters;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace SampleApplication
|
|
|
|
|
{
|
|
|
|
|
public class MapHeadingToVisibilityConverter : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
|
|
|
{
|
2025-09-16 17:33:29 +02:00
|
|
|
var visible = (double)value != 0d;
|
2025-09-16 14:18:29 +02:00
|
|
|
#if AVALONIA
|
2025-09-16 17:33:29 +02:00
|
|
|
return visible;
|
2025-09-16 14:18:29 +02:00
|
|
|
#else
|
2025-09-16 17:33:29 +02:00
|
|
|
return visible ? Visibility.Visible : Visibility.Collapsed;
|
2025-09-16 14:18:29 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-16 17:33:29 +02:00
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
2025-09-16 14:18:29 +02:00
|
|
|
{
|
2025-09-16 17:33:29 +02:00
|
|
|
return Convert(value, targetType, parameter, culture.ToString());
|
2025-09-16 14:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-16 17:33:29 +02:00
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
2025-09-16 14:18:29 +02:00
|
|
|
{
|
2025-09-16 17:33:29 +02:00
|
|
|
throw new NotImplementedException();
|
2025-09-16 14:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
{
|
2025-09-16 17:33:29 +02:00
|
|
|
throw new NotImplementedException();
|
2025-09-16 14:18:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|