Skip to content

窗口

流畅窗口 (FluentWindow)

  • 可通过 TitleBarContent 定义窗口标题栏内的内容
xml
<wnd:FluentWindow
  x:Class="MSFNavTest.MainWindow"
  xmlns="https://github.com/avaloniaui"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:fi="clr-namespace:AvaloniaFluentUI.Icons;assembly=AvaloniaFluentUI"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:primitives="clr-namespace:AvaloniaFluentUI.Controls.Primitives;assembly=AvaloniaFluentUI"
  xmlns:ui="clr-namespace:AvaloniaFluentUI.Controls;assembly=AvaloniaFluentUI"
  xmlns:wnd="clr-namespace:AvaloniaFluentUI.Windowing;assembly=AvaloniaFluentUI"
  Title="Frameless Window"
  d:DesignHeight="450"
  d:DesignWidth="800"
  Icon="C:\Projects\C#\Avalonia-Fluent-UI\samples\Gallery\Assets\app.ico"
  mc:Ignorable="d">

  <wnd:FluentWindow.TitleBarContent>
    <Grid ColumnDefinitions="*, Auto, Auto, Auto">
      <ui:SearchTextBox
        Grid.Column="0"
        MinWidth="268"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        PlaceholderText="请输入内容"/>

      <ui:Avatar
        Grid.Column="1"
        Width="32"
        Height="32"
        Margin="0,0,12,0"
        VerticalAlignment="Center"
        IsCircular="True"
        Source="avares://MSFNavTest/Assets/avatar.jpg"/>
      <ui:ToolButton
        Grid.Column="2"
        Width="46"
        Height="45"
        Classes="Transparent"
        Content="{x:Static fi:FluentIcon.Setting}"/>
      <ui:ToolButton
        Grid.Column="3"
        Width="46"
        Height="45"
        Classes="Transparent"
        Content="{x:Static fi:FluentIcon.Pin}"/>
    </Grid>
  </wnd:FluentWindow.TitleBarContent>
</wnd:FluentWindow>

WARNING

如果是1.0.3及以前的版本, 如果设置了TitleBarContent, 需设置TitleBarHitTestTypeTitleBarHitTestType.Complex, 否则会出现无法点击标题栏内容的情况

  • 通过EnableMica(true) EnabledAcrylicBlur(true) 启用窗口效果

拆分窗口

xml
<wnd:FluentWindow
  x:Class="MSFNavTest.MainWindow"
  xmlns="https://github.com/avaloniaui"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:fi="clr-namespace:AvaloniaFluentUI.Icons;assembly=AvaloniaFluentUI"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:primitives="clr-namespace:AvaloniaFluentUI.Controls.Primitives;assembly=AvaloniaFluentUI"
  xmlns:ui="clr-namespace:AvaloniaFluentUI.Controls;assembly=AvaloniaFluentUI"
  xmlns:wnd="clr-namespace:AvaloniaFluentUI.Windowing;assembly=AvaloniaFluentUI"
  Title="Frameless Window"
  d:DesignHeight="450"
  d:DesignWidth="800"
  Icon="C:\Projects\C#\Avalonia-Fluent-UI\samples\Gallery\Assets\app.ico"
  TitleBarMargin="50 0 0 0"
  mc:Ignorable="d">

  <wnd:FluentWindow.TitleBarContent>
    <Grid ColumnDefinitions="*, Auto, Auto, Auto">
      <ui:SearchTextBox
        Grid.Column="0"
        MinWidth="268"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        PlaceholderText="请输入内容"/>

      <ui:Avatar
        Grid.Column="1"
        Width="32"
        Height="32"
        Margin="0,0,12,0"
        VerticalAlignment="Center"
        IsCircular="True"
        Source="avares://MSFNavTest/Assets/avatar.jpg"/>
      <ui:ToolButton
        Grid.Column="2"
        Width="46"
        Height="45"
        Classes="Transparent"
        Content="{x:Static fi:FluentIcon.Setting}"/>
      <ui:ToolButton
        Grid.Column="3"
        Width="46"
        Height="45"
        Classes="Transparent"
        Content="{x:Static fi:FluentIcon.Pin}"/>
    </Grid>
  </wnd:FluentWindow.TitleBarContent>

  <ui:NavigationView
    Name="NavigationView"
    AlwaysShowHeader="False"
    Background="Transparent"
    IsBackButtonVisible="True"
    IsBackEnabled="True"
    IsSettingsVisible="True"
    PaneDisplayMode="Left"
    PaneTitle="设置">

    <ui:NavigationView.AutoCompleteBox>
      <ui:SearchTextBox/>
    </ui:NavigationView.AutoCompleteBox>

    <ui:NavigationView.MenuItems>
      <ui:NavigationViewItem
        Content="Home"
        IconSource="M5.322 32q-0.884 0-1.66-0.334t-1.36-0.918-0.918-1.36-0.334-1.66v-12.997q0-0.634 0.25-1.235t0.684-1.034l11.378-11.362q0.534-0.534 1.21-0.818t1.426-0.284 1.427 0.284 1.21 0.818l11.378 11.362q0.434 0.434 0.684 1.034t0.25 1.235v12.997q0 0.884-0.334 1.66t-0.918 1.36-1.36 0.918-1.66 0.334h-6.407q-0.45 0-0.843-0.167t-0.676-0.45-0.45-0.676-0.167-0.843v-8.542h-4.271v8.542q0 0.45-0.167 0.834t-0.459 0.676-0.676 0.459-0.834 0.167h-6.407zM11.729 29.864v-8.542q0-0.45 0.167-0.834t0.459-0.676 0.676-0.459 0.834-0.167h4.271q0.434 0 0.826 0.167t0.684 0.459 0.459 0.684 0.167 0.826v8.542h6.407q0.45 0 0.834-0.167t0.676-0.459 0.459-0.676 0.167-0.834v-12.997q0-0.434-0.317-0.751l-11.362-11.379q-0.467-0.467-1.135-0.467t-1.135 0.467l-11.362 11.379q-0.317 0.317-0.317 0.751v12.997q0 0.45 0.167 0.843t0.45 0.676 0.676 0.45 0.843 0.167h6.407z"
        IsSelected="True"
        Tag="Home"/>
      <ui:NavigationViewItem
        Content="Icon"
        IconSource="M30 20.109v-2.109h2v6h-6v-2h3q-0.703-0.938-1.766-1.469t-2.234-0.531q-0.797 0-1.531 0.242t-1.359 0.68-1.094 1.047-0.734 1.359l-1.875-0.656q0.375-1.047 1.031-1.906t1.523-1.477 1.898-0.953 2.141-0.336q1.422 0 2.719 0.539t2.281 1.57zM7 0q1.453 0 2.727 0.547t2.227 1.5 1.5 2.227 0.547 2.727-0.547 2.727-1.5 2.227-2.227 1.5-2.727 0.547-2.727-0.547-2.227-1.5-1.5-2.227-0.547-2.727 0.547-2.727 1.5-2.227 2.227-1.5 2.727-0.547zM2 7q0 1.031 0.391 1.945t1.070 1.594 1.594 1.070 1.945 0.391q0.734 0 1.438-0.211t1.313-0.617l-6.922-6.922q-0.406 0.609-0.617 1.313t-0.211 1.438zM4.25 2.828l6.922 6.922q0.406-0.609 0.617-1.313t0.211-1.438q0-1.031-0.398-1.938t-1.078-1.586-1.586-1.078-1.938-0.398q-0.734 0-1.438 0.211t-1.313 0.617zM25 30q0.797 0 1.531-0.242t1.352-0.68 1.094-1.047 0.742-1.359l1.875 0.656q-0.375 1.047-1.031 1.906t-1.523 1.477-1.898 0.953-2.141 0.336q-1.422 0-2.719-0.539t-2.281-1.57v2.109h-2v-6h6v2h-3q0.703 0.938 1.766 1.469t2.234 0.531zM25 13.906l-5.781-5.766q-0.594-0.594-0.906-1.352t-0.313-1.602q0-0.859 0.328-1.625t0.891-1.336 1.32-0.898 1.633-0.328q0.797 0 1.523 0.281t1.305 0.813q0.578-0.531 1.305-0.813t1.523-0.281q0.859 0 1.625 0.328t1.328 0.898 0.891 1.336 0.328 1.625q0 0.844-0.313 1.602t-0.906 1.352l-5.781 5.766zM22.188 3q-0.453 0-0.852 0.172t-0.695 0.469-0.469 0.695-0.172 0.852q0 0.438 0.164 0.828t0.477 0.703l4.359 4.359 4.359-4.359q0.641-0.641 0.641-1.531 0-0.453-0.172-0.852t-0.469-0.695-0.695-0.469-0.852-0.172-0.836 0.164-0.695 0.477l-1.281 1.281-1.281-1.281q-0.313-0.313-0.703-0.477t-0.828-0.164zM6 18h2v6h6v2h-6v6h-2v-6h-6v-2h6v-6z"
        Tag="Icons"/>
      <ui:NavigationViewItem
        Content="BasicInput"
        IconSource="M3.922 32q-0.781 0-1.492-0.32t-1.25-0.859-0.859-1.25-0.32-1.492v-24.156q0-0.781 0.32-1.492t0.859-1.25 1.25-0.859 1.492-0.32h24.156q0.781 0 1.492 0.32t1.25 0.859 0.859 1.25 0.32 1.492v24.156q0 0.781-0.32 1.492t-0.859 1.25-1.25 0.859-1.492 0.32h-24.156zM28 30q0.422 0 0.781-0.156t0.633-0.43 0.43-0.633 0.156-0.781v-24q0-0.406-0.156-0.773t-0.43-0.641-0.641-0.43-0.773-0.156h-24q-0.422 0-0.781 0.156t-0.633 0.43-0.43 0.633-0.156 0.781v24q0 0.422 0.156 0.789t0.422 0.633 0.633 0.422 0.789 0.156h24zM6 15q0-0.406 0.297-0.703t0.703-0.297 0.703 0.297l5.297 5.281 11.297-11.281q0.297-0.297 0.703-0.297t0.703 0.297 0.297 0.703-0.297 0.703l-12 12q-0.297 0.297-0.703 0.297t-0.703-0.297l-6-6q-0.297-0.297-0.297-0.703z"
        Tag="BasicInput"/>
      <ui:NavigationViewItem
        Content="DialogAndPopup"
        IconSource="M0 31q0-0.406 0.133-0.844t0.227-0.828q0.359-1.484 0.75-2.938t0.75-2.938q-0.922-1.719-1.391-3.594t-0.469-3.828q0-2.203 0.57-4.258t1.609-3.836 2.5-3.242 3.242-2.508 3.828-1.617 4.25-0.57 4.242 0.57 3.82 1.617 3.242 2.5 2.508 3.234 1.617 3.82 0.57 4.242q0 2.188-0.57 4.227t-1.602 3.82-2.484 3.25-3.227 2.516-3.805 1.625-4.234 0.578q-1.938 0-3.813-0.445t-3.594-1.336l-7.438 1.75q-0.156 0.031-0.234 0.031-0.422 0-0.711-0.289t-0.289-0.711zM15.938 30q1.938 0 3.734-0.5t3.359-1.406 2.852-2.18 2.203-2.836 1.414-3.359 0.5-3.734-0.5-3.727-1.414-3.336-2.195-2.828-2.844-2.188-3.352-1.406-3.711-0.5-3.711 0.5-3.344 1.406-2.828 2.18-2.188 2.82-1.414 3.336-0.5 3.711q0 1.016 0.125 1.875t0.359 1.68 0.563 1.633 0.75 1.703q0.125 0.25 0.125 0.484 0 0.172-0.094 0.641t-0.25 1.078-0.336 1.313-0.352 1.344-0.313 1.164-0.203 0.773q1.063-0.25 2.102-0.5t2.102-0.516q0.531-0.125 1.109-0.297t1.125-0.172q0.125 0 0.234 0.039t0.234 0.086q0.844 0.391 1.633 0.711t1.586 0.539 1.641 0.344 1.797 0.125zM11 14q-0.406 0-0.703-0.297t-0.297-0.703 0.297-0.703 0.703-0.297h10q0.406 0 0.703 0.297t0.297 0.703-0.297 0.703-0.703 0.297h-10zM11 20q-0.406 0-0.703-0.297t-0.297-0.703 0.297-0.703 0.703-0.297h6q0.406 0 0.703 0.297t0.297 0.703-0.297 0.703-0.703 0.297h-6z"
        Tag="DialogBoxAndPopup"/>
      <ui:NavigationViewItem
        Content="Layout"
        IconSource="M26.411 0q1.125 0 2.143 0.455t1.777 1.214 1.214 1.777 0.455 2.143v20.822q0 1.125-0.455 2.143t-1.214 1.777-1.777 1.214-2.143 0.455h-20.822q-1.125 0-2.143-0.455t-1.777-1.214-1.214-1.777-0.455-2.143v-20.822q0-1.125 0.455-2.143t1.214-1.777 1.777-1.214 2.143-0.455h20.822zM5.714 2.286q-0.696 0-1.321 0.268t-1.098 0.741-0.741 1.098-0.268 1.321v14.857h16v-18.286h-12.572zM29.714 5.714q0-0.696-0.268-1.321t-0.741-1.098-1.098-0.741-1.321-0.268h-5.714v6.857h9.143v-3.429zM29.714 11.429h-9.143v9.143h9.143v-9.143zM2.286 26.286q0 0.696 0.268 1.321t0.741 1.098 1.098 0.741 1.321 0.268h5.714v-6.857h-9.143v3.429zM26.286 29.714q0.696 0 1.321-0.268t1.098-0.741 0.741-1.098 0.268-1.321v-3.429h-16v6.857h12.572z"
        Tag="Layout"/>
      <ui:NavigationViewItem
        Content="Navigation"
        IconSource="M1 25h30l0.379 0.074 0.324 0.223 0.223 0.324 0.074 0.379-0.074 0.379-0.223 0.324-0.324 0.223-0.379 0.074h-30l-0.379-0.074-0.324-0.223-0.223-0.324-0.074-0.379 0.074-0.379 0.223-0.324 0.324-0.223 0.379-0.074zM1 15h30l0.379 0.074 0.324 0.223 0.223 0.324 0.074 0.379-0.074 0.379-0.223 0.324-0.324 0.223-0.379 0.074h-30l-0.379-0.074-0.324-0.223-0.223-0.324-0.074-0.379 0.074-0.379 0.223-0.324 0.324-0.223 0.379-0.074zM1 5h30l0.379 0.074 0.324 0.223 0.223 0.324 0.074 0.379-0.074 0.379-0.223 0.324-0.324 0.223-0.379 0.074h-30l-0.379-0.074-0.324-0.223-0.223-0.324-0.074-0.379 0.074-0.379 0.223-0.324 0.324-0.223 0.379-0.074z"
        Tag="Navigation"/>
      <ui:NavigationViewItem
        Content="Text"
        IconSource="M9.922 22.344h-5.844l-2.156 5.375q-0.125 0.281-0.359 0.453t-0.547 0.172q-0.406 0-0.711-0.281t-0.305-0.703q0-0.188 0.078-0.391l6-15q0.25-0.625 0.922-0.625 0.359 0 0.563 0.164t0.359 0.461q0.141 0.281 0.25 0.602t0.234 0.617l1.141 2.844q0.859 2.156 1.711 4.281t1.711 4.266l5.484-14.625 1.828-4.859q0.188-0.516 0.375-1.055t0.406-1.039q0.141-0.297 0.367-0.477t0.57-0.18q0.359 0 0.578 0.18t0.359 0.477q0.172 0.359 0.305 0.766t0.273 0.781l1.359 3.625 4.063 10.844q0.109 0.281 0.375 0.969t0.609 1.57 0.711 1.852 0.672 1.797 0.5 1.422 0.195 0.719q0 0.422-0.289 0.711t-0.711 0.289q-0.313 0-0.57-0.18t-0.367-0.477l-2.75-7.344h-10.625l-2.75 7.344q-0.109 0.297-0.359 0.477t-0.563 0.18-0.563-0.164-0.375-0.461l-2.156-5.375zM22 6.188l-4.563 12.156h9.125l-4.563-12.156zM7 15.031l-2.125 5.313h4.25l-2.125-5.313z"
        Tag="Text"/>
      <ui:NavigationViewItem
        Content="View"
        IconSource="M0 19.675q0-0.097 0.032-0.258 0.499-1.867 1.312-3.573t1.924-3.171 2.487-2.648 2.986-2.028 3.437-1.296 3.823-0.451q2.318 0 4.467 0.66t4.016 1.851 3.396 2.857 2.592 3.694q0.161 0.306 0.418 0.901t0.507 1.255 0.427 1.264 0.177 0.91q0 0.419-0.306 0.724t-0.724 0.306-0.628-0.217-0.37-0.572q-0.177-0.37-0.258-0.773t-0.209-0.789q-0.37-1.175-1.006-2.318t-1.408-2.109q-1.030-1.32-2.286-2.358t-2.688-1.755-3.010-1.095-3.268-0.378q-1.996 0-3.847 0.596t-3.461 1.65-2.93 2.511-2.237 3.179q-0.113 0.209-0.306 0.628t-0.386 0.885-0.33 0.885-0.137 0.628q0 0.241-0.088 0.491t-0.241 0.451-0.37 0.338-0.475 0.137q-0.418 0-0.724-0.29t-0.306-0.724zM8.789 19.514q0-1.449 0.588-2.736t1.578-2.254 2.294-1.529 2.753-0.563q1.481 0 2.793 0.571t2.294 1.553 1.553 2.294 0.571 2.793-0.571 2.793-1.553 2.294-2.294 1.553-2.793 0.571q-1.529 0-2.849-0.58t-2.286-1.577-1.521-2.334-0.555-2.849zM21.151 19.53q0-1.046-0.419-1.964t-1.127-1.602-1.642-1.078-1.964-0.394q-1.078 0-2.012 0.402t-1.634 1.103-1.103 1.634-0.402 2.012 0.402 2.012 1.103 1.634 1.634 1.103 2.012 0.402q1.111 0 2.052-0.41t1.626-1.127 1.079-1.674 0.394-2.052z"
        Tag="View"/>
      <ui:NavigationViewItem
        Content="Scroll"
        IconSource="M10 7.313v19.594q0 0.406-0.297 0.703t-0.703 0.297-0.703-0.297-0.297-0.703v-19.594l-6.297 6.297q-0.297 0.297-0.703 0.297t-0.703-0.297-0.297-0.703 0.297-0.703l7.953-7.953q0.172-0.172 0.344-0.258t0.406-0.086 0.406 0.086 0.344 0.258l7.953 7.953q0.297 0.297 0.297 0.703t-0.297 0.703-0.703 0.297-0.703-0.297l-6.297-6.297zM32 18.906q0 0.406-0.297 0.703l-7.953 7.953q-0.172 0.172-0.336 0.258t-0.414 0.086-0.414-0.086-0.336-0.258l-7.953-7.953q-0.297-0.297-0.297-0.703t0.297-0.703 0.703-0.297 0.703 0.297l6.297 6.281v-19.578q0-0.406 0.297-0.703t0.703-0.297 0.703 0.297 0.297 0.703v19.578l6.297-6.281q0.297-0.297 0.703-0.297t0.703 0.297 0.297 0.703z"
        Tag="Scroll"/>
      <ui:NavigationViewItem
        Content="StatusAndInformation"
        IconSource="M6 22.391q-0.172 0.063-0.578 0.203t-0.93 0.32-1.086 0.367-1.063 0.352-0.867 0.266-0.477 0.102q-0.422 0-0.711-0.305t-0.289-0.711q0-0.109 0.094-0.492t0.242-0.906 0.32-1.125 0.336-1.148 0.297-0.969 0.18-0.594q-1.469-2.703-1.469-5.75 0-1.656 0.43-3.188t1.211-2.867 1.875-2.43 2.43-1.875 2.867-1.211 3.188-0.43q2.484 0 4.664 0.945t3.813 2.578 2.578 3.813 0.945 4.664q0 1.656-0.43 3.188t-1.211 2.867-1.875 2.43-2.43 1.875-2.867 1.211-3.188 0.43q-1.578 0-3.102-0.406t-2.898-1.203zM22 12q0-2.078-0.781-3.898t-2.141-3.18-3.18-2.141-3.898-0.781-3.898 0.781-3.18 2.141-2.141 3.18-0.781 3.898q0 1.422 0.367 2.641t1.023 2.469q0.078 0.125 0.109 0.242t0.031 0.273q0 0.125-0.063 0.414t-0.164 0.656-0.227 0.781-0.242 0.797-0.211 0.703-0.141 0.477q0.219-0.063 0.75-0.258t1.117-0.391 1.086-0.352 0.656-0.156q0.297 0 0.563 0.156 0.656 0.375 1.281 0.656t1.273 0.484 1.336 0.305 1.453 0.102q2.078 0 3.898-0.781t3.18-2.141 2.141-3.18 0.781-3.898zM9 11q-0.406 0-0.703-0.297t-0.297-0.703 0.297-0.703 0.703-0.297h6q0.406 0 0.703 0.297t0.297 0.703-0.297 0.703-0.703 0.297h-6zM9.484 25.766q1.234 0.234 2.516 0.234 1.453 1.906 3.523 2.953t4.477 1.047q0.766 0 1.445-0.102t1.328-0.297 1.281-0.484 1.289-0.664q0.266-0.156 0.563-0.156 0.156 0 0.656 0.156t1.086 0.352 1.117 0.391 0.75 0.258q-0.047-0.156-0.141-0.477t-0.211-0.703-0.242-0.797-0.227-0.781-0.164-0.656-0.063-0.414q0-0.156 0.031-0.273t0.109-0.242q0.328-0.625 0.586-1.234t0.438-1.234 0.273-1.273 0.094-1.367q0-1.172-0.273-2.305t-0.789-2.164-1.258-1.93-1.68-1.602q0-1.234-0.219-2.516 1.422 0.766 2.57 1.891t1.961 2.484 1.25 2.906 0.438 3.156q0 1.563-0.352 3.008t-1.102 2.82q0.047 0.172 0.18 0.602t0.289 0.977 0.336 1.148 0.32 1.125 0.234 0.898 0.094 0.484q0 0.406-0.289 0.711t-0.711 0.305q-0.109 0-0.477-0.102t-0.859-0.266-1.063-0.352-1.086-0.367-0.922-0.32-0.578-0.203q-1.469 0.828-2.969 1.219t-3.172 0.391q-1.609 0-3.148-0.445t-2.891-1.258-2.469-1.969-1.883-2.563zM9 15q-0.406 0-0.703-0.297t-0.297-0.703 0.297-0.703 0.703-0.297h4q0.406 0 0.703 0.297t0.297 0.703-0.297 0.703-0.703 0.297h-4z"
        Tag="StatusAndInformation"/>
      <ui:NavigationViewItem
        Content="MenuAndToolBar"
        IconSource="M3.429 13.714q-0.696 0-1.321-0.268t-1.098-0.741-0.741-1.098-0.268-1.321v-6.857q0-0.696 0.268-1.321t0.741-1.098 1.098-0.741 1.321-0.268h11.429q0.696 0 1.321 0.268t1.098 0.741 0.741 1.098 0.268 1.321v6.857q0 0.696-0.268 1.321t-0.741 1.098-1.098 0.741-1.321 0.268h-11.429zM26.286 13.714q-0.697 0-1.322-0.268t-1.098-0.741-0.741-1.098-0.268-1.321v-6.857q0-0.696 0.268-1.321t0.741-1.098 1.098-0.741 1.322-0.268h2.286q0.696 0 1.321 0.268t1.098 0.741 0.741 1.098 0.268 1.321v6.857q0 0.696-0.268 1.321t-0.741 1.098-1.098 0.741-1.321 0.268h-2.286zM14.857 11.429q0.464 0 0.804-0.339t0.339-0.803v-6.857q0-0.464-0.339-0.804t-0.804-0.339h-11.429q-0.464 0-0.804 0.339t-0.339 0.804v6.857q0 0.464 0.339 0.803t0.804 0.339h11.429zM28.571 11.429q0.464 0 0.804-0.339t0.339-0.803v-6.857q0-0.464-0.339-0.804t-0.804-0.339h-2.286q-0.464 0-0.804 0.339t-0.339 0.804v6.857q0 0.464 0.339 0.803t0.804 0.339h2.286zM3.429 32q-0.696 0-1.321-0.268t-1.098-0.741-0.741-1.098-0.268-1.321v-6.857q0-0.696 0.268-1.321t0.741-1.098 1.098-0.741 1.321-0.268h2.286q0.697 0 1.322 0.268t1.098 0.741 0.741 1.098 0.268 1.321v6.857q0 0.696-0.268 1.321t-0.741 1.098-1.098 0.741-1.322 0.268h-2.286zM17.143 32q-0.696 0-1.321-0.268t-1.098-0.741-0.741-1.098-0.268-1.321v-6.857q0-0.696 0.268-1.321t0.741-1.098 1.098-0.741 1.321-0.268h11.429q0.696 0 1.321 0.268t1.098 0.741 0.741 1.098 0.268 1.321v6.857q0 0.696-0.268 1.321t-0.741 1.098-1.098 0.741-1.321 0.268h-11.429zM5.714 29.714q0.464 0 0.804-0.339t0.339-0.804v-6.857q0-0.464-0.339-0.804t-0.804-0.339h-2.286q-0.464 0-0.804 0.339t-0.339 0.804v6.857q0 0.464 0.339 0.804t0.804 0.339h2.286zM28.571 29.714q0.464 0 0.804-0.339t0.339-0.804v-6.857q0-0.464-0.339-0.804t-0.804-0.339h-11.429q-0.464 0-0.803 0.339t-0.339 0.804v6.857q0 0.464 0.339 0.804t0.803 0.339h11.429z"
        Tag="MenuAndToolBar"/>
      <ui:NavigationViewItem
        Content="DateTime"
        IconSource="M11.35 27.733q0.283 0.567 0.608 1.1t0.708 1.033h-6.4q-1.25 0-2.392-0.508t-2-1.367-1.367-2-0.508-2.392v-17.333q0-1.25 0.508-2.392t1.367-2 2-1.367 2.392-0.508h17.333q1.25 0 2.392 0.508t2 1.367 1.367 2 0.508 2.392v6.4q-0.5-0.383-1.033-0.708t-1.1-0.608v-2.817h-25.6v15.017q0 0.867 0.35 1.625t0.933 1.325 1.358 0.9 1.625 0.333h4.95zM6.317 2.133q-0.85 0-1.617 0.35t-1.333 0.933-0.9 1.358-0.333 1.625h25.6v-0.083q0-0.833-0.342-1.592t-0.917-1.333-1.333-0.917-1.592-0.342h-17.233zM32 22.4q0 1.983-0.758 3.733t-2.058 3.050-3.050 2.058-3.733 0.758q-2 0-3.75-0.75t-3.050-2.050-2.050-3.050-0.75-3.75q0-1.983 0.758-3.733t2.058-3.050 3.050-2.058 3.733-0.758q1.317 0 2.542 0.342t2.292 0.967 1.95 1.508 1.508 1.95 0.967 2.292 0.342 2.542zM25.6 23.467q0.433 0 0.75-0.317t0.317-0.75-0.317-0.75-0.75-0.317h-2.133v-3.2q0-0.433-0.317-0.75t-0.75-0.317-0.75 0.317-0.317 0.75v4.267q0 0.433 0.317 0.75t0.75 0.317h3.2z"
        Tag="DateTime"/>
    </ui:NavigationView.MenuItems>
  </ui:NavigationView>
</wnd:FluentWindow>
csharp
Application.Current.Resources["NavigationViewContentGridCornerRadius"] = new CornerRadius(0);

NavigationView.PropertyChanged += (_, e) =>
{
    if (e.Property == NavigationView.IsPaneOpenProperty)
    {
        TitleBarMargin = new Thickness(NavigationView.IsPaneOpen ? NavigationView.OpenPaneLength + 12 : 50, 0, 0, 0);
    }
};

启动页面

继承IApplicationSplashScreen实现成员方法

  • SplashScreenContent 启动页面内容
  • RunTasks 启动页面任务
  • MinimumShowTime 启动页面最小显示时间
csharp
using AvaloniaFluentUI.Controls.Windowing;

namespace Test.Views;

public partial class MainWindow : AppWindow 
{
    public MainWindow()
    {
        InitializeComponent();

        TitleBarIsVisible = false;
        SplashScreen = new MainWindowSplashScreen(() => TitleBarIsVisible = true);
    }
}

class MainWindowSplashScreen : IApplicationSplashScreen
{
    private Action Action { get; } = action;
    
    public object SplashScreenContent => new TextBlock
    {
        Text = "Application Splash Screen",
        FontSize = 32,
        HorizontalAlignment = HorizontalAlignment.Center,
        VerticalAlignment = VerticalAlignment.Center,
    };
    
    public async Task RunTasks(CancellationToken cancellationToken)
    {
        await Task.Delay(2000, cancellationToken);
        Action.Invoke();
    }

    public int MinimumShowTime => 2000;
}

基于 MIT 许可发布