GithubHelp home page GithubHelp logo

navigationapp's Introduction

Navigation Sample

This is an Example of how to achieve navigation in avalonia ui to elaborate more on stack overflow question

Output

How To Run

it Require .NET7 ... to run the NavigationApp.Desktop

cd ./NavigationApp.Desktop
dotnet run

Technologies

  • .NET 7
  • avalonia UI V11.0.5
  • Community ToolKit

Explanation

your problem is a navigation problem ... and there is a different solution to solve this but simple thing should be simple

for each screen you need View and ViewModel To suport this screen

/root
├── ViewModels
│   ├── TerminalConfigureViewModel
│   ├── ServerConfigureViewModel
│   └── AdminViewModel
│
├── Views
│   ├── TerminalConfigureView
│   ├── ServerConfigureView
│   └── AdminView

Now we need to tell avaloniat that if you try to rander one of the Viewmodels How to choos the correct view (By help of data templates)

<Application.DataTemplates>
   <DataTemplate DataType="{x:Type vm:ServerConfigureViewModel}">
     <view:ServerConfigureView/>      
   </DataTemplate>

   <DataTemplate DataType="{x:Type vm:TerminalConfigureViewModel}">
     <view:TerminalConfigureView/>
   </DataTemplate>

   <DataTemplate DataType="{x:Type vm:AdminViewModel}">
     <view:AdminView/>
   </DataTemplate>
 </Application.DataTemplates>

or the more Easy Solution to Depend on the naming convention. if you want rander this ViewModels.{name}ViewModel Use this view Views.{name}View (Read about ViewLocator)

in the MainViewModel We also have property called CurrentViewModel which is randered to the MainView if you change this property avalonia know how to rander it

Summary

navigationapp's People

Contributors

ibram-reda avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.