跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
其他技能

avalonia-controls-layout

Use when working with Avalonia layout container controls: Border, ScrollViewer, SplitView, Expander, GroupBox (12.0+), Viewbox, or Panel variants (Grid, StackPanel, WrapPanel, DockPanel, UniformGrid, Canvas). Covers container-specific API, properties, scroll configuration, and layout pitfalls in Avalonia 12.

linuxdevel · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add linuxdevel/Avalonia-skills --skill avalonia-controls-layout

技能说明


name: avalonia-controls-layout description: Use when working with Avalonia layout container controls: Border, ScrollViewer, SplitView, Expander, GroupBox (12.0+), Viewbox, or Panel variants (Grid, StackPanel, WrapPanel, DockPanel, UniformGrid, Canvas). Covers container-specific API, properties, scroll configuration, and layout pitfalls in Avalonia 12.

Avalonia Layout Controls

Overview

Layout controls are containers that position and constrain child controls. See avalonia-layout for general sizing/alignment concepts. This skill covers the container control APIs.


Border

Single-child container. Adds background, border, rounded corners, padding, and shadows.

PropertyTypeNotes
BackgroundIBrushFill color
BorderBrushIBrushBorder color
BorderThicknessThickness1 or 1,2,1,2 (L,T,R,B)
CornerRadiusCornerRadius8 or 8,0,8,0 (TL,TR,BR,BL)
PaddingThicknessInner spacing
BoxShadowBoxShadowsDrop shadow(s)
ChildControlSingle child only
<!-- Card style -->
<Border Background="White"
        CornerRadius="8"
        BorderBrush="#E0E0E0"
        BorderThickness="1"
        Padding="16"
        BoxShadow="0 2 8 0 #20000000">
    <StackPanel Spacing="8">
        <TextBlock Text="Card Title" FontWeight="SemiBold" FontSize="16"/>
        <TextBlock Text="Card body content goes here." TextWrapping="Wrap"/>
    </StackPanel>
</Border>

<!-- Divider line using Border -->
<Border Height="1" Background="#E0E0E0" Margin="0,8"/>

<!-- Multiple box shadows -->
<Border BoxShadow="0 1 3 0 #1A000000, 0 4 6 0 #0D000000" CornerRadius="6" Padding="12">
    <TextBlock Text="Elevated card"/>
</Border>

Important: Border only accepts one child. Wrap multiple children in a Panel, StackPanel, or Grid.


ScrollViewer

Adds scrollbars to content that overflows its bounds.

PropertyTypeNotes
HorizontalScrollBarVisibilityScrollBarVisibilityAuto, Visible, Hidden, Disabled
VerticalScrollBarVisibilityScrollBarVisibilityAuto, Visible, Hidden, Disabled
OffsetVectorProgrammatic scroll position
ExtentSizeTotal content size
ViewportSizeVisible area size
AllowAutoHideboolHides scrollbar when not hovering
HorizontalSnapPointsTypeSnapPointsTypeSnap behavior

ScrollBarVisibility values:

ValueBehavior
AutoShows when content overflows
VisibleAlways shown
HiddenNever shown, but scrolling still works
DisabledDisables scrolling in that direction
<!-- Standard vertical scroll -->
<ScrollViewer VerticalScrollBarVisibility="Auto"
              HorizontalScrollBarVisibility="Disabled">
    <StackPanel>
        <!-- many items -->
    </StackPanel>
</ScrollViewer>

<!-- Horizontal scroll (e.g. wide table) -->
<ScrollViewer HorizontalScrollBarVisibility="Auto"
              VerticalScrollBarVisibility="Disabled">
    <Grid Width="1200"><!-- wide content --></Grid>
</ScrollViewer>
// Programmatic scroll
scrollViewer.Offset = new Vector(0, 500);

// Scroll to end
scrollViewer.ScrollToEnd();

// Subscribe to scroll events
scrollViewer.ScrollChanged += (s, e) =>
{
    bool atBottom = scrollViewer.Offset.Y >= scrollViewer.ScrollBarMaximum.Y;
};

Pitfall: ScrollViewer inside StackPanel never scrolls because StackPanel gives infinite height. Fix: use a Grid row with Height="*" or set an explicit Height on the ScrollViewer.


SplitView

Two-region layout: a collapsible pane and main content area.

PropertyTypeNotes
IsPaneOpenboolTwoWay — controls pane visibility
OpenPaneLengthdoubleWidth when expanded
CompactPaneLengthdoubleWidth when compact (icon-only)
DisplayModeSplitViewDisplayModeSee table below
PanePlacementSplitViewPanePlacementLeft (default), Right
PaneobjectPane content
ContentobjectMain content area

DisplayMode values:

ModeBehavior
OverlayPane overlaps content when open
InlinePane pushes content when open
CompactOverlayShows CompactPaneLength strip; expands over content
CompactInlineShows CompactPaneLength strip; expands pushing content
<SplitView IsPaneOpen="{Binding IsNavOpen}"
           DisplayMode="CompactInline"
           OpenPaneLength="220"
           CompactPaneLength="48">
    <SplitView.Pane>
        <StackPanel Spacing="4" Margin="4">
            <Button Command="{Binding NavHomeCommand}" HorizontalAlignment="Stretch">
                <StackPanel Orientation="Horizontal" Spacing="12">
                    <PathIcon Data="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" Width="20" Height="20"/>
                    <TextBlock Text="Home" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
            <Button Command="{Binding NavSettingsCommand}" HorizontalAlignment="Stretch">
                <StackPanel Orientation="Horizontal" Spacing="12">
                    <PathIcon Data="M19.14 12.94..." Width="20" Height="20"/>
                    <TextBlock Text="Settings" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
        </StackPanel>
    </SplitView.Pane>
    <ContentControl Content="{Binding CurrentPage}"/>
</SplitView>

Note: Pane and Content are set via XAML property element syntax, not as items in a Children collection.


Expander

Collapsible section with a header.

PropertyTypeNotes
HeaderobjectAlways-visible header (string or XAML)
IsExpandedboolTwoWay — controls expand state
ExpandDirectionExpandDirectionDown (default), Up, Left, Right
ContentTransition
阅读完整来源 ↗