diff --git a/docs/guides/development-guides/how-to-show-and-hide-a-split-view-pane-with-mvvm.md b/docs/guides/development-guides/how-to-show-and-hide-a-split-view-pane-with-mvvm.md index 5f77c5bd8..2325b121a 100644 --- a/docs/guides/development-guides/how-to-show-and-hide-a-split-view-pane-with-mvvm.md +++ b/docs/guides/development-guides/how-to-show-and-hide-a-split-view-pane-with-mvvm.md @@ -3,17 +3,378 @@ id: how-to-show-and-hide-a-split-view-pane-with-mvvm title: How To Show and Hide a Split View Pane with MVVM --- -import SplitViewExpanderScreenshot from '/img/reference/controls/splitview/splitview-expander.gif'; +import FirstExample from '/img/guides/development-guides/How-to-show-and-hide-a-split-view-pane-with-MVVM/First-example.PNG'; +import SecondExample from '/img/guides/development-guides/How-to-show-and-hide-a-split-view-pane-with-MVVM/Second-example.PNG'; +import PaneHidden from '/img/guides/development-guides/How-to-show-and-hide-a-split-view-pane-with-MVVM/Pane-Hidden.PNG'; +import PaneShown from '/img/guides/development-guides/How-to-show-and-hide-a-split-view-pane-with-MVVM/Pane-shown.PNG'; -Content in preparation. +# How To Show and Hide a Split View Pane with MVVM +In this guide you will learn how to show and hide a split view panel using the MVVM pattern. If you are new to Avalonia UI please check out the following documents: [The MVVM pattern](https://docs.avaloniaui.net/docs/concepts/the-mvvm-pattern/) - [Avalonia UI and MVVM](https://docs.avaloniaui.net/docs/concepts/the-mvvm-pattern/avalonia-ui-and-mvvm). +To proceed in this guide you will need at least a basic understanding of what Data Binding is and how it works in Avalonia. -You can use the MVVM pattern with the split view control to implement a 'tool pane' style UI. +## Starting +First of all, you need to create an MVVM application project, which you can do by reading the following guide [Create and run a project](https://docs.avaloniaui.net/docs/get-started/test-drive/create-a-project).
+Once you created the project you should be presented with the following files: +- MainWindow.axaml +- MainWindowViewModel.cs +Those are the files you will be editing the most. Please note that additional files may need to be created as you proceed through this guide. + +:::info +Although in this guide we will be using the MainWindow.axaml and MainWindowViewModel.cs files, this guide will work for every additional View and ViewModel you may create. +::: + +## Adding the SplitView panel to the MainWindow +Open the MainWindow.xaml file. The default MVVM project template will generate a project populated with the following default files: +``` xml + + + + + + + + + + +``` + +For the sake of simplicity we will be deleting the default TextBlock and its value in the MainWindowViewModel. +
+Now, create the SplitView and define the basics of how you want it to behave (for more information on how this control works see [here](https://docs.avaloniaui.net/docs/reference/controls/splitview)) +``` xml + + +``` +If you used this same code you should see the following window when starting the application. The light grey panel on the right is the one you will be expanding at the end of this guide. +First example + +## Adding the SplitView's pane +Now that we have the SplitView we need to create its pane, which is the part that will be hidden when the split view is closed. +``` xml + + + + + +``` +We will now add some additional elements to the pane. First a StackPanel, then a button and a textbox with the text "Settings". The following configurations will ensure that the button and the text are aligned. +``` xml + + + +