ViewHeightScrollable
LayoutProvides scrollable content area that scrolls through physical lines of any content. Has all functionalities of default Scrollable.
@using RazorConsole.Components
@using Spectre.Console
@using Markup = RazorConsole.Components.Markup
@using Panel = RazorConsole.Components.Panel
<Markup Content="Use tab to change focus and arrow up/down + num keys to scroll"/>
<Newline/>
<ViewHeightScrollable Scrollbar="new()" LinesToRender="10">
<Panel Title="View Height scrollable with some markdown content" Border="BoxBorder.Rounded">
<Markdown Content="@_largeText"/>
</Panel>
</ViewHeightScrollable>
@code {
private readonly string _largeText =@"
#### Counter.razor
```razor
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Web
@using RazorConsole.Components
<Columns>
<p>Current count</p>
<Markup Content=""@currentCount.ToString()"" Foreground=""@Spectre.Console.Color.Green"" />
</Columns>
<TextButton Content=""Click me""
OnClick=""IncrementCount""
BackgroundColor=""@Spectre.Console.Color.Grey""
FocusedColor=""@Spectre.Console.Color.Blue"" />
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
```
#### Program.cs
```csharp
using Microsoft.Extensions.Hosting;
using RazorConsole.Core;
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args)
.UseRazorConsole<Counter>();
IHost host = hostBuilder.Build();
await host.RunAsync();
```
".Trim();
}Parameters
6| Name | Type | Default | Description |
|---|---|---|---|
Events | |||
ScrollOffsetChanged | EventCallback<Int32> | — | Event callback invoked when the scroll offset changes. |
Common | |||
ChildContent | RenderFragment<ScrollContext> | — | — |
Other | |||
IsScrollbarEmbedded | Boolean | — | Flag that determines will scrollbar be embedded or not. |
LinesToRender | Int32 | — | Number of lines visible at one time. |
ScrollOffset | Int32 | — | Current scroll offset (index of the first visible line). |
Scrollbar | ScrollbarSettings | — | Scrollbar settings. If provided, the scrollbar is enabled. |