csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
// This source file is adapted from the WinUI project.
|
|
// (https://github.com/microsoft/microsoft-ui-xaml)
|
|
//
|
|
// Licensed to The Avalonia Project under MIT License, courtesy of The .NET Foundation.
|
|
|
|
using System;
|
|
|
|
namespace Avalonia.Layout
|
|
{
|
|
internal class LayoutContextAdapter : VirtualizingLayoutContext
|
|
{
|
|
private readonly NonVirtualizingLayoutContext _nonVirtualizingContext;
|
|
|
|
public LayoutContextAdapter(NonVirtualizingLayoutContext nonVirtualizingContext)
|
|
{
|
|
_nonVirtualizingContext = nonVirtualizingContext;
|
|
}
|
|
|
|
protected override object LayoutStateCore
|
|
{
|
|
get => _nonVirtualizingContext.LayoutState;
|
|
set => _nonVirtualizingContext.LayoutState = value;
|
|
}
|
|
|
|
protected override Point LayoutOriginCore
|
|
{
|
|
get => default;
|
|
set
|
|
{
|
|
if (value != default)
|
|
{
|
|
throw new InvalidOperationException("LayoutOrigin must be at (0,0) when RealizationRect is infinite sized.");
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override Rect RealizationRectCore() => new Rect(Size.Infinity);
|
|
|
|
protected override int ItemCountCore() => _nonVirtualizingContext.Children.Count;
|
|
protected override object GetItemAtCore(int index) => _nonVirtualizingContext.Children[index];
|
|
protected override ILayoutable GetOrCreateElementAtCore(int index, ElementRealizationOptions options) =>
|
|
_nonVirtualizingContext.Children[index];
|
|
protected override void RecycleElementCore(ILayoutable element) { }
|
|
}
|
|
}
|
|
|