During an attempt to lock 2 AvaloniaEdit vertical/horizontal offsets I encountered some issues. It seems that ScrollToHorizontalOffset and ScrollToVerticalOffset was never implemented (or commented out) at some point. Avalonia 11.2 ScrollViewer does not have this API currently.
The underlying ScrollViewer is internal, so I'm not sure what the best approach is.
/// <summary>
/// Scrolls to the specified position in the document.
/// </summary>
public void ScrollToHorizontalOffset(double offset)
{
ApplyTemplate(); // ensure scrollViewer is created
//if (scrollViewer != null)
// scrollViewer.ScrollToHorizontalOffset(offset);
}
/// <summary>
/// Scrolls to the specified position in the document.
/// </summary>
public void ScrollToVerticalOffset(double offset)
{
ApplyTemplate(); // ensure scrollViewer is created
//if (scrollViewer != null)
// scrollViewer.ScrollToVerticalOffset(offset);
}
Edit: I tested a simple solution which works fine.
/// <summary>
/// Scrolls to the specified position in the document.
/// </summary>
public void ScrollToHorizontalOffset(double offset)
{
ApplyTemplate(); // ensure scrollViewer is created
if (ScrollViewer != null)
ScrollViewer.SetValue(ScrollViewer.OffsetProperty, new Vector(offset, ScrollViewer.Offset.Y));
}
/// <summary>
/// Scrolls to the specified position in the document.
/// </summary>
public void ScrollToVerticalOffset(double offset)
{
ApplyTemplate(); // ensure scrollViewer is created
if (ScrollViewer != null)
ScrollViewer.SetValue(ScrollViewer.OffsetProperty, new Vector(ScrollViewer.Offset.X, offset));
}
Version: 11.1.0
During an attempt to lock 2 AvaloniaEdit vertical/horizontal offsets I encountered some issues. It seems that ScrollToHorizontalOffset and ScrollToVerticalOffset was never implemented (or commented out) at some point. Avalonia 11.2 ScrollViewer does not have this API currently.
The underlying ScrollViewer is internal, so I'm not sure what the best approach is.
Edit: I tested a simple solution which works fine.