MenuView created and tested
This commit is contained in:
parent
83a71b807d
commit
af7db6b95d
@ -5,5 +5,9 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Project.View.MainWindow"
|
||||
Title="Project.View">
|
||||
Welcome to Avalonia!
|
||||
</Window>
|
||||
|
||||
<Grid Name="MainGrid">
|
||||
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
|
||||
@ -7,5 +7,6 @@ public partial class MainWindow : Window
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
MainGrid.Children.Add(new MenuView());
|
||||
}
|
||||
}
|
||||
17
Project.View/MenuView/MenuView.axaml
Normal file
17
Project.View/MenuView/MenuView.axaml
Normal file
@ -0,0 +1,17 @@
|
||||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
x:Class="Project.View.MenuView"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid>
|
||||
|
||||
<StackPanel>
|
||||
<Button Click="Button_Click" Width="250" Height="100" Content="XAMPEPE0" />
|
||||
<Button Width="250" Height="100" Content="XAMPEPE2" />
|
||||
<Button Width="250" Height="100" Content="XAMPEPE3" />
|
||||
<Button Width="250" Height="100" Content="XAMPEPE4" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
</UserControl>
|
||||
23
Project.View/MenuView/MenuView.axaml.cs
Normal file
23
Project.View/MenuView/MenuView.axaml.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Project.View;
|
||||
|
||||
public partial class MenuView : UserControl
|
||||
{
|
||||
public MenuView()
|
||||
{
|
||||
InitializeComponent();
|
||||
// Das ist der Workaround, falls unten nicht funktioniert:
|
||||
//this.FindControl<Grid>("mainGrid").Children.Add(new Menu());
|
||||
|
||||
//funktioniert manchmal nicht!
|
||||
//MainGrid.Children.Add(new Menu())
|
||||
}
|
||||
|
||||
private void Button_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
((Button)sender).Background = Brushes.Blue;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user