add a basic menus page.

This commit is contained in:
Dan Walmsley 2020-06-16 16:45:18 -03:00
parent 7a2afeb2b6
commit d74a14d2d0
5 changed files with 82 additions and 75 deletions

View File

@ -0,0 +1,40 @@
<UserControl 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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="XamlControlsGallery.Pages.MenusPage">
<Panel Margin="{StaticResource PageMargin}" MinWidth="100" MinHeight="100">
<Menu VerticalAlignment="Top" HorizontalAlignment="Left">
<MenuItem Header="File">
<MenuItem Header="New" InputGesture="CTRL + N" />
<MenuItem Header="Open" />
<Separator />
<MenuItem Header="Exit" InputGesture="Alt + F4" />
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Header="Cut" InputGesture="CTRL + X" />
<MenuItem Header="Copy" InputGesture="CTRL + C" />
<MenuItem Header="Paste" InputGesture="CTRL + V" />
</MenuItem>
<MenuItem Header="Options">
<MenuItem Header="Compact Mode Enabled">
<MenuItem.Icon>
<Viewbox Width="16" VerticalAlignment="Center">
<Path Fill="White" Margin="0 -2 0 0" Data="M1024 1408q79 0 149 -30t122.5 -82.5t82.5 -122.5t30 -149q0 -80 -30 -149.5t-82.5 -122t-122.5 -82.5t-149 -30q-80 0 -149.5 30t-122 82.5t-82.5 122t-30 149.5q0 79 30 149t82.5 122.5t122 82.5t149.5 30z" />
</Viewbox>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Menu with _Submenu">
<MenuItem Header="Submenu _1"/>
<MenuItem Header="Submenu _2"/>
</MenuItem>
<MenuItem Header="Menu Item with _Icon" InputGesture="Ctrl+Shift+B">
<MenuItem.Icon>
<Image Source="/Assets/avalonia-logo.ico"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</Menu>
</Panel>
</UserControl>

View File

@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace XamlControlsGallery.Pages
{
public class MenusPage : UserControl
{
public MenusPage()
{
this.InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -1,12 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using Avalonia.Controls;
using System.Collections.Generic;
using System.Reactive;
using ReactiveUI;
namespace XamlControlsGallery.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
private bool _isMenuItemChecked;
public MainWindowViewModel()
{
ToggleMenuItemCheckedCommand = ReactiveCommand.Create(() =>
{
IsMenuItemChecked = !IsMenuItemChecked;
});
}
public bool IsMenuItemChecked
{
get { return _isMenuItemChecked; }
set { this.RaiseAndSetIfChanged(ref _isMenuItemChecked, value); }
}
public ReactiveCommand<Unit, Unit> ToggleMenuItemCheckedCommand { get; }
public string Greeting => "Welcome to Avalonia!";
public List<string> SearchItems { get; } = new List<string>

View File

@ -107,7 +107,7 @@
<pages:MediaPage />
</TabItem>
<TabItem Header="Menus">
<pages:MenusPage />
</TabItem>
<TabItem Header="Navigation">
@ -126,70 +126,4 @@
</TabItem>
</TabControl>
</Panel>
<!-- TODO Move to fluent window template -->
<!--<Panel Margin="{Binding #MainWindow.OffScreenMargin}">
<DockPanel VerticalAlignment="Stretch">
<ExperimentalAcrylicBorder DockPanel.Dock="Left" Width="240">
<ExperimentalAcrylicBorder.Material>
<ExperimentalAcrylicMaterial TintColor="Black" MaterialOpacity="0.85" TintOpacity="1" />
</ExperimentalAcrylicBorder.Material>
<StackPanel Spacing="20" TextBlock.Foreground="White" Margin="0 40 0 0">
<ItemsControl>
<ItemsControl.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Margin" Value="0 0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="TextBlock.FontWeight" Value="Light" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
<Style Selector="ListBoxItem > TextBlock">
<Setter Property="Margin" Value="10 5" />
</Style>
</ItemsControl.Styles>
<ListBoxItem>
<TextBlock Text="Overview" VerticalAlignment="Center"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="Text Input" />
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="Date and Time"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="Dialogs and Flyouts"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="Layout"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="Media"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="Menus and Toolbars"/>
</ListBoxItem>
</ItemsControl>
</StackPanel>
</ExperimentalAcrylicBorder>
<Panel>
<ExperimentalAcrylicBorder IsHitTestVisible="False">
<ExperimentalAcrylicBorder.Material>
<ExperimentalAcrylicMaterial TintColor="#222222" MaterialOpacity="0.85" TintOpacity="1" />
</ExperimentalAcrylicBorder.Material>
</ExperimentalAcrylicBorder>
<TextBlock Text="Overview" Margin="40 20" FontSize="32" FontWeight="Light" />
<Panel.Styles>
<Style Selector="TextBlock.header">
<Setter Property="Margin" Value="0 30 0 20" />
</Style>
</Panel.Styles>
<ScrollViewer Margin="0 60 0 0" HorizontalScrollBarVisibility="Auto">
</ScrollViewer>
</Panel>
</DockPanel>
</Panel>-->
</FluentWindow>

View File

@ -17,9 +17,6 @@
</AvaloniaResource>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\teapot.bin" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\teapot.bin" />
</ItemGroup>
@ -28,5 +25,5 @@
<PackageReference Include="Avalonia.Diagnostics" Version="0.9.999-cibuild0008416-beta" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.999-cibuild0008416-beta" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.999-cibuild0008416-beta" />
</ItemGroup>
</ItemGroup>
</Project>