添加菜单按钮

This commit is contained in:
末城via 2023-01-03 12:21:54 +08:00
parent c52f20bfbe
commit bc3d5ddf42
2 changed files with 22 additions and 1 deletions

View File

@ -16,7 +16,8 @@
<UniformGrid Columns="5"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="投喂">
<MenuItem x:Name="MenuFeed"
Header="投喂">
<MenuItem Header="食物" />
<MenuItem Header="饮料" />
<MenuItem Header="药品" />

View File

@ -72,5 +72,25 @@ namespace VPet_Simulator.Core
{
m.Core.Controller.ShowSetting();
}
public void AddMenuButton(string parentMenu,
string displayName,
Action clickCallback)
{
var menuItem = new MenuItem()
{
Header = displayName,
};
menuItem.Click += delegate
{
clickCallback?.Invoke();
};
switch (parentMenu)
{
case "投喂":
MenuFeed.Items.Add(menuItem);
break;
}
}
}
}