BasicToolbar.axaml代码

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Height="229.6" Width="562.4"
        x:Class="AvaloniaUI.BasicToolbar"
        Title="BasicToolbar">
    <Grid RowDefinitions="auto,*">
        <ToolBar Grid.Row="0">
            <!-- 图标资源 -->
            <Button Content="{StaticResource DownloadFile}"/>
        </ToolBar>
        <ToolBarTray Grid.Row="0" Background="AliceBlue">
            <ToolBar>
                <!-- 图标资源 -->
                <Button Content="{StaticResource DownloadFile}"/>
            </ToolBar>
            
            <ToolBar>
                <Button Content="Open"/>
                
                <Border Width="1"
                         Margin="5,2"
                         VerticalAlignment="Stretch"
                         Background="Gray"/>    
                
                <Button Content="Save"/>
                <Button Content="Close"/>
            </ToolBar>

            <ToolBar>
                <CheckBox FontWeight="Bold" Content="Bold" Margin="5"/>
                <CheckBox FontStyle="Italic" Content="Italic" Margin="5"/>
                <CheckBox Margin="5">
                    <TextBlock TextDecorations="Underline" Text="Underline"/>
                </CheckBox>    
            </ToolBar>
            
            <ToolBar VerticalAlignment="Center">
                <ComboBox SelectedIndex="0">
                    <ComboBoxItem Content="100%"/>
                    <ComboBoxItem Content="50%"/>
                    <ComboBoxItem Content="25%"/>
                </ComboBox>
            </ToolBar>
        </ToolBarTray>
        
        <!-- 内容区占位 -->
        <Border Grid.Row="1" Background="WhiteSmoke"/>
    </Grid>
</Window>

BasicToolbar.axaml.cs代码

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace AvaloniaUI;

public partial class BasicToolbar : Window
{
    public BasicToolbar()
    {
        InitializeComponent();
    }
}

运行效果

image

 

posted on 2026-04-13 02:03  dalgleish  阅读(4)  评论(0)    收藏  举报