private void SetMenu(NativeMenu menu) { var appMenu = _factory.ObtainAppMenu(); if (appMenu is null) { appMenu = _factory.CreateMenu(); } var menuItem = menu.Parent; if (menu.Parent is null) { menuItem = new NativeMenuItem(); } menuItem.Menu = menu; appMenu.Clear(); AddItemsToMenu(appMenu, new List <NativeMenuItemBase> { menuItem }); _factory.SetAppMenu(appMenu); }