feat: 添加Usercontrol

master
朱雅鸿 2022-11-06 14:49:30 +08:00
parent 8c69aed40f
commit ec5fb3f3ad
7 changed files with 40 additions and 24 deletions

View File

@ -1,7 +1,15 @@
namespace LoraGamepad.ViewModels namespace LoraGamepad.ViewModels
{ {
public class MainWindowViewModel : ViewModelBase public class MainWindowViewModel : ViewModelBase
{ {
public string Greeting => "Welcome to Avalonia!";
public TProViewModel TProViewModels { get; }
public MainWindowViewModel()
{
TProViewModels = new TProViewModel();
} }
}
} }

View File

@ -0,0 +1,9 @@
namespace LoraGamepad.ViewModels;
public class TProViewModel : ViewModelBase
{
public TProViewModel()
{
}
}

View File

@ -1,6 +0,0 @@
namespace LoraGamepad.ViewModels;
public class TPROWindowViewModel
{
}

View File

@ -1,6 +1,7 @@
<Window xmlns="https://github.com/avaloniaui" <Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:LoraGamepad.ViewModels" xmlns:vm="using:LoraGamepad.ViewModels"
xmlns:views="clr-namespace:LoraGamepad.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
@ -12,6 +13,5 @@
<vm:MainWindowViewModel/> <vm:MainWindowViewModel/>
</Design.DataContext> </Design.DataContext>
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/> <ContentControl Content="{Binding TProViewModels}" />
</Window> </Window>

View File

@ -0,0 +1,17 @@
<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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="LoraGamepad.Views.TProView">
<DockPanel>
<Button DockPanel.Dock="Bottom"
HorizontalAlignment="Center">
Add an item
</Button>
<StackPanel>
<CheckBox Margin="4">Walk the dog</CheckBox>
<CheckBox Margin="4">Buy some milk</CheckBox>
</StackPanel>
</DockPanel>
</UserControl>

View File

@ -4,14 +4,11 @@ using Avalonia.Markup.Xaml;
namespace LoraGamepad.Views; namespace LoraGamepad.Views;
public partial class TPROWindow : Window public partial class TProView : UserControl
{ {
public TPROWindow() public TProView()
{ {
InitializeComponent(); InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
} }
private void InitializeComponent() private void InitializeComponent()

View File

@ -1,9 +0,0 @@
<Window 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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="LoraGamepad.Views.TPROWindow"
Title="TPROWindow">
Welcome to Avalonia!
</Window>