|
1 | 1 | <UserControl xmlns="https://github.com/avaloniaui" |
2 | | - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
3 | | - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
4 | | - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
5 | | - xmlns:views="clr-namespace:Vocup.Views;assembly=Vocup.Avalonia" |
6 | | - xmlns:vm="clr-namespace:Vocup.ViewModels;assembly=Vocup.Avalonia" |
7 | | - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
8 | | - x:Class="Vocup.Views.MainView" |
9 | | - x:DataType="vm:MainViewModel"> |
| 2 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:views="clr-namespace:Vocup.Views;assembly=Vocup.Avalonia" |
| 6 | + xmlns:vm="clr-namespace:Vocup.ViewModels;assembly=Vocup.Avalonia" |
| 7 | + mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
| 8 | + x:Class="Vocup.Views.MainView" |
| 9 | + x:DataType="vm:MainViewModel"> |
10 | 10 |
|
11 | | - <Design.DataContext> |
12 | | - <!-- This only sets the DataContext for the previewer in an IDE, |
13 | | - to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> |
14 | | - <vm:MainViewModel /> |
15 | | - </Design.DataContext> |
| 11 | + <Design.DataContext> |
| 12 | + <!-- This only sets the DataContext for the previewer in an IDE, |
| 13 | + to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> |
| 14 | + <vm:MainViewModel /> |
| 15 | + </Design.DataContext> |
16 | 16 |
|
17 | | - <Grid RowDefinitions="Auto, *" ColumnDefinitions="Auto, *, Auto" Margin="4"> |
18 | | - <Button Command="{Binding OpenFileCommand}" Content="Open File" Grid.Row="0" Grid.Column="0" /> |
19 | | - <Button Command="{Binding AboutCommand}" Content="About" Grid.Row="0" Grid.Column="2" /> |
20 | | - <ContentControl Content="{Binding CurrentView}" Grid.Row="1" Grid.ColumnSpan="3" /> |
21 | | - </Grid> |
| 17 | + <UserControl.Resources> |
| 18 | + <ResourceDictionary> |
| 19 | + <views:DoubleLessOrEqualConverter x:Key="DoubleLessOrEqualConverter" /> |
| 20 | + |
| 21 | + <!-- |
| 22 | + Theme Variant specific styles only work through resources: |
| 23 | + https://github.com/AvaloniaUI/Avalonia/discussions/20444 |
| 24 | + --> |
| 25 | + <ResourceDictionary.ThemeDictionaries> |
| 26 | + <ResourceDictionary x:Key="Light"> |
| 27 | + <x:String x:Key="Css">path { fill: #000; }</x:String> |
| 28 | + </ResourceDictionary> |
| 29 | + <ResourceDictionary x:Key="Dark"> |
| 30 | + <x:String x:Key="Css">path { fill: #fff; }</x:String> |
| 31 | + </ResourceDictionary> |
| 32 | + </ResourceDictionary.ThemeDictionaries> |
| 33 | + </ResourceDictionary> |
| 34 | + </UserControl.Resources> |
| 35 | + |
| 36 | + <SplitView Name="splitView" Classes.toggleable="{Binding Bounds.Width, ElementName=splitView, Converter={StaticResource DoubleLessOrEqualConverter}, ConverterParameter=800}"> |
| 37 | + <SplitView.Styles> |
| 38 | + <Style Selector="SplitView.toggleable"> |
| 39 | + <Setter Property="DisplayMode" Value="Overlay" /> |
| 40 | + <Setter Property="OpenPaneLength" Value="{Binding Bounds.Width, ElementName=splitView}" /> |
| 41 | + <Setter Property="IsPaneOpen" Value="{Binding IsPaneOpen}" /> |
| 42 | + </Style> |
| 43 | + <Style Selector="SplitView:not(.toggleable)"> |
| 44 | + <Setter Property="DisplayMode" Value="Inline" /> |
| 45 | + <Setter Property="OpenPaneLength" Value="240" /> |
| 46 | + <Setter Property="IsPaneOpen" Value="True" /> |
| 47 | + </Style> |
| 48 | + <Style Selector="Svg"> |
| 49 | + <Setter Property="(Svg.Css)" Value="{DynamicResource Css}" /> |
| 50 | + </Style> |
| 51 | + |
| 52 | + </SplitView.Styles> |
| 53 | + <SplitView.Pane> |
| 54 | + <Grid RowDefinitions="Auto, *, Auto" ColumnDefinitions="Auto" Margin="4"> |
| 55 | + <Button Command="{Binding OpenFileCommand}" Grid.Row="0" Grid.Column="0"> |
| 56 | + <StackPanel Orientation="Horizontal" Spacing="8"> |
| 57 | + <Svg Path="/Assets/file-regular-full.svg" Width="16" Height="16" /> |
| 58 | + <TextBlock Text="Open Book" VerticalAlignment="Center" /> |
| 59 | + </StackPanel> |
| 60 | + </Button> |
| 61 | + <Button Command="{Binding AboutCommand}" Content="About" Grid.Row="2" Grid.Column="0" /> |
| 62 | + </Grid> |
| 63 | + </SplitView.Pane> |
| 64 | + |
| 65 | + <Grid RowDefinitions="Auto, *"> |
| 66 | + <Button Grid.Row="0" Margin="4" Command="{Binding TogglePaneCommand}"> |
| 67 | + <Button.Styles> |
| 68 | + <Style Selector="SplitView:not(.toggleable) Button"> |
| 69 | + <Setter Property="IsVisible" Value="False" /> |
| 70 | + </Style> |
| 71 | + </Button.Styles> |
| 72 | + <Svg Path="/Assets/bars-solid-full.svg" Width="16" Height="16" /> |
| 73 | + </Button> |
| 74 | + <ContentControl Grid.Row="1" Content="{Binding CurrentView}" /> |
| 75 | + </Grid> |
| 76 | + |
| 77 | + </SplitView> |
22 | 78 |
|
23 | 79 | </UserControl> |
0 commit comments