my project was created with the visual studio tempalte, support desktop ,android and web.
MainViewModel:
public class MainViewModel : ViewModelBase
{
ViewModelBase _CurrentViewModel;
public ViewModelBase CurrentViewModel
{
get { return _CurrentViewModel; }
private set { this.RaiseAndSetIfChanged(ref _CurrentViewModel, value); }
}
public MainViewModel()
{
_CurrentViewModel=new LoginViewModel();
}
}
MainView.axaml:
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:App1.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:CompileBindings="True"
x:Class="App1.Views.MainView"
x:DataType="vm:MainViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>
<Grid>
<TransitioningContentControl Content="{Binding CurrentViewModel}"></TransitioningContentControl>
</Grid>
</UserControl>
LoginViewModel:
public class LoginViewModel : ViewModelBase
{
public LoginViewModel() { }
}
my project was created with the visual studio tempalte, support desktop ,android and web.
MainViewModel
:MainView.axaml
:LoginViewModel
:LoginView.axaml
:when run it , the main window only show the full name of the view model. I hope it show the login view