Fix styles as Styles (not ResourceDictionary); replace DataTriggers with width converters; add IsZeroConverter; remove unsupported properties; fix ancestor command bindings; bind SplitView props directly.
This commit is contained in:
parent
c624127bf9
commit
1667fc8b3d
9 changed files with 146 additions and 101 deletions
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace AdvancedCalculator.Converters;
|
||||
|
||||
public class WidthToSplitViewModeConverter : IValueConverter
|
||||
{
|
||||
public static readonly WidthToSplitViewModeConverter Instance = new();
|
||||
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo? culture)
|
||||
{
|
||||
if (value is double width)
|
||||
{
|
||||
double threshold = 640;
|
||||
if (parameter is double p)
|
||||
threshold = p;
|
||||
else if (parameter is string s && double.TryParse(s, NumberStyles.Number, CultureInfo.InvariantCulture, out var parsed))
|
||||
threshold = parsed;
|
||||
|
||||
return width < threshold ? SplitViewDisplayMode.Overlay : SplitViewDisplayMode.Inline;
|
||||
}
|
||||
return SplitViewDisplayMode.Inline;
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo? culture)
|
||||
=> throw new NotSupportedException();
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue