Moved Menu into SplitView - Added Button to open SplitView
This commit is contained in:
+2
-2
@@ -19,7 +19,7 @@
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.4" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.4" />
|
||||
<PackageReference Include="Avalonia.Xaml.Interactions" Version="11.2.0.8" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1"/>
|
||||
<PackageReference Include="Avalonia.Xaml.Interactions" Version="11.2.0.9" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -11,6 +12,8 @@ public class MainWindowViewModel : ViewModelBase
|
||||
#pragma warning disable CA1822 // Mark members as static
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
DisplaySplitEvent = new RelayCommand(DisplaySplit);
|
||||
|
||||
ColorPalette =
|
||||
[
|
||||
new ColorPickerButton
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media;
|
||||
@@ -36,4 +37,26 @@ public class ViewModelBase : ObservableObject
|
||||
get => _brushThickness;
|
||||
set => SetProperty(ref _brushThickness, value);
|
||||
}
|
||||
|
||||
private double _buttonOffset = 0;
|
||||
|
||||
public double ButtonOffset
|
||||
{
|
||||
get => _buttonOffset;
|
||||
set => SetProperty(ref _buttonOffset, value);
|
||||
}
|
||||
|
||||
private bool _isSplitOpen = false;
|
||||
|
||||
public bool IsSplitOpen
|
||||
{
|
||||
get => _isSplitOpen;
|
||||
set => SetProperty(ref _isSplitOpen, value);
|
||||
}
|
||||
|
||||
public IRelayCommand DisplaySplitEvent { get; protected set; }
|
||||
protected void DisplaySplit()
|
||||
{
|
||||
IsSplitOpen = !IsSplitOpen;
|
||||
}
|
||||
}
|
||||
|
||||
+32
-16
@@ -11,6 +11,9 @@
|
||||
xmlns:componentModel="clr-namespace:CommunityToolkit.Mvvm.ComponentModel;assembly=CommunityToolkit.Mvvm"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
TransparencyLevelHint="Transparent"
|
||||
TransparencyBackgroundFallback="DimGray"
|
||||
Background="Transparent"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="SimpleDraw"
|
||||
Width="{Binding WindowWidth}"
|
||||
@@ -29,8 +32,20 @@
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
|
||||
<DockPanel>
|
||||
<Menu DockPanel.Dock="Top">
|
||||
<Panel Background="Transparent">
|
||||
<SplitView Background="Transparent" IsPaneOpen="{Binding IsSplitOpen, Mode=TwoWay}" DisplayMode="Overlay" OpenPaneLength="250">
|
||||
<SplitView.Pane>
|
||||
<Border Background="Transparent" BorderBrush="Gray" BorderThickness="2">
|
||||
<Grid Background="Transparent">
|
||||
<Grid Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"></RowDefinition>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<DockPanel Grid.Row="0" Background="Transparent">
|
||||
<Menu DockPanel.Dock="Top" Background="Transparent" HorizontalAlignment="Left">
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_Open..."/>
|
||||
<Separator/>
|
||||
@@ -41,18 +56,9 @@
|
||||
<MenuItem Header="Paste"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Grid Background="Gray">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="105"></ColumnDefinition>
|
||||
<ColumnDefinition Width="1*" MinWidth="300"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Column="0" Background="LightGray">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0">
|
||||
</DockPanel>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<TextBox Text="Select Color:" IsHitTestVisible="False" IsReadOnly="True" BorderThickness="0" Background="Transparent"/>
|
||||
<ItemsControl ItemsSource="{Binding ColorPalette}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
@@ -82,6 +88,9 @@
|
||||
<Slider Margin="5, 0" Value="{Binding BrushThickness}" Maximum="50" Minimum="0.5"></Slider>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</SplitView.Pane>
|
||||
<Canvas Grid.Column="1" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<i:Interaction.Behaviors>
|
||||
<behaviors:EventTriggerBehavior EventName="PointerPressed">
|
||||
@@ -118,6 +127,13 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</SplitView>
|
||||
<Button Content="≡" Command="{Binding DisplaySplitEvent}" HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||
<Button.RenderTransform>
|
||||
<TranslateTransform X="{Binding ButtonOffset}" />
|
||||
</Button.RenderTransform>
|
||||
<Button.Transitions>
|
||||
</Button.Transitions>
|
||||
</Button>
|
||||
</Panel>
|
||||
</Window>
|
||||
|
||||
Reference in New Issue
Block a user