mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
添加菜单按钮
This commit is contained in:
parent
c52f20bfbe
commit
bc3d5ddf42
@ -16,7 +16,8 @@
|
||||
<UniformGrid Columns="5"/>
|
||||
</ItemsPanelTemplate>
|
||||
</Menu.ItemsPanel>
|
||||
<MenuItem Header="投喂">
|
||||
<MenuItem x:Name="MenuFeed"
|
||||
Header="投喂">
|
||||
<MenuItem Header="食物" />
|
||||
<MenuItem Header="饮料" />
|
||||
<MenuItem Header="药品" />
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user