Added main menu
This commit is contained in:
parent
1ded5ab913
commit
c199722e81
@ -7,9 +7,20 @@
|
||||
Width="640" Height="480"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="AvaloniaCoreRTDemo">
|
||||
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" Margin="32">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" TextAlignment="Center" Margin="0,6">Welcome to Avalonia UI + CoreRT!</TextBlock>
|
||||
<Image Grid.Row="1" Grid.Column="0" Stretch="None" Source="{Binding DotNetImage}"></Image>
|
||||
<Image Grid.Row="1" Grid.Column="1" Stretch="None" Source="{Binding AvaloniaImage}"></Image>
|
||||
</Grid>
|
||||
<DockPanel>
|
||||
<Menu DockPanel.Dock="Top">
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_Exit" Command="{Binding FileExitCommand}"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Help">
|
||||
<MenuItem Header="About"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" Margin="32">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" TextAlignment="Center" Margin="0,6">Welcome to Avalonia UI + CoreRT!</TextBlock>
|
||||
<Image Grid.Row="1" Grid.Column="0" Stretch="None" Source="{Binding DotNetImage}"></Image>
|
||||
<Image Grid.Row="1" Grid.Column="1" Stretch="None" Source="{Binding AvaloniaImage}"></Image>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
</Window>
|
||||
|
@ -2,10 +2,6 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media.Imaging;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using Path = System.IO.Path;
|
||||
|
||||
namespace AvaloniaCoreRTDemo
|
||||
{
|
||||
@ -14,7 +10,7 @@ namespace AvaloniaCoreRTDemo
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new ViewModel();
|
||||
this.DataContext = new MainWindowViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
@ -22,27 +18,4 @@ namespace AvaloniaCoreRTDemo
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewModel: ReactiveObject
|
||||
{
|
||||
public ViewModel()
|
||||
{
|
||||
DotNetImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dotnet.png"));
|
||||
AvaloniaImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "avalonia.png"));
|
||||
}
|
||||
|
||||
private IBitmap dotNetImage;
|
||||
public IBitmap DotNetImage
|
||||
{
|
||||
get { return dotNetImage; }
|
||||
set { this.RaiseAndSetIfChanged(ref this.dotNetImage, value); }
|
||||
}
|
||||
|
||||
private IBitmap avaloniaImage;
|
||||
public IBitmap AvaloniaImage
|
||||
{
|
||||
get { return avaloniaImage; }
|
||||
set { this.RaiseAndSetIfChanged(ref this.avaloniaImage, value); }
|
||||
}
|
||||
}
|
||||
}
|
49
MainWindowViewModel.cs
Normal file
49
MainWindowViewModel.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Media.Imaging;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using Path = System.IO.Path;
|
||||
|
||||
namespace AvaloniaCoreRTDemo
|
||||
{
|
||||
public class MainWindowViewModel: ReactiveObject
|
||||
{
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
DotNetImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dotnet.png"));
|
||||
AvaloniaImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "avalonia.png"));
|
||||
|
||||
FileExitCommand = ReactiveCommand.Create(RunFileExit);
|
||||
HelpAboutCommand = ReactiveCommand.Create(RunHelpAbout);
|
||||
}
|
||||
|
||||
public IBitmap DotNetImage
|
||||
{
|
||||
get { return dotNetImage; }
|
||||
set { this.RaiseAndSetIfChanged(ref this.dotNetImage, value); }
|
||||
}
|
||||
|
||||
public IBitmap AvaloniaImage
|
||||
{
|
||||
get { return avaloniaImage; }
|
||||
set { this.RaiseAndSetIfChanged(ref this.avaloniaImage, value); }
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> FileExitCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> HelpAboutCommand { get; }
|
||||
|
||||
void RunFileExit()
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
void RunHelpAbout()
|
||||
{
|
||||
// Code for executing the command here.
|
||||
}
|
||||
|
||||
private IBitmap dotNetImage;
|
||||
private IBitmap avaloniaImage;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user