Перейти к основному содержимому
Версия: 0.10.x

DependencyProperty

The Avalonia equivalent of DependencyProperty is StyledProperty, however Avalonia has a richer property system than WPF, and includes DirectProperty for turning standard CLR properties into Avalonia properties. The common base class of StyledProperty and DirectProperty is AvaloniaProperty.

If your dependency property uses FrameworkPropertyMetadataOptions.AffectsMeasure now you should use AffectsMeasure<TControl>(MyProperty) to obtain desired effect.

WPF

// SplitterPanel control
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register(
"Orientation",
typeof(Orientation),
typeof(SplitterPanel),
new FrameworkPropertyMetadata(
Orientation.Horizontal,
FrameworkPropertyMetadataOptions.AffectsMeasure));

Avalonia

// SplitterPanel control
public static readonly StyledProperty<Orientation> OrientationProperty =
AvaloniaProperty.Register<SplitterPanel, Orientation>(nameof(Orientation), Orientation.Horizontal);

static SplitterPanel()
{
AffectsMeasure<SplitterPanel>(OrientationProperty);
}