Skip to content

Commit

Permalink
Menubar (#4839)
Browse files Browse the repository at this point in the history
* Menu Bar

* - wire up all the handlers and classes

* - remove extra type

* - rework menu elements

* - fixup WinUI MenuBar placement

* - add interfaces

* - Cleanup interfaces

* - remove text style APIs

* - wire up icon

* - fix interface

* - stream line inheritance a bit more

* - fix

* - fixup some builder

* - fixup menu selector calls

* - fixed sub menu items

* - demo code

* - fix rebase

* - centralize menu code

* - start the fun

* - move menubaritems to page

* - MenuBar Page

* - add additional clicks

* - fixup types

* - Catalyst images/clicks

* - wire images

* - Add Tests

* - remove DesktopSupportTestPage

* - add check for selector when adding menu items
  • Loading branch information
PureWeen authored Feb 24, 2022
1 parent e51ea7a commit cbace2d
Show file tree
Hide file tree
Showing 80 changed files with 3,100 additions and 904 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla52700.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39407.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ButtonFastRendererTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DesktopSupportTestPage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla58779.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla51825.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla31688.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ void SetupMenuItems(MenuFlyout flyout)
{
foreach (MenuItem item in Cell.ContextActions)
{
var flyoutItem = new MenuFlyoutItem();
flyoutItem.SetBinding(MenuFlyoutItem.TextProperty, "Text");
var flyoutItem = new UI.Xaml.Controls.MenuFlyoutItem();
flyoutItem.SetBinding(UI.Xaml.Controls.MenuFlyoutItem.TextProperty, "Text");
//WINUI FIX
//flyoutItem.Command = new MenuItemCommand(item);
flyoutItem.DataContext = item;
Expand Down
4 changes: 2 additions & 2 deletions src/Compatibility/Core/src/Windows/CellControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ void SetupMenuItems(MenuFlyout flyout)
{
foreach (MenuItem item in Cell.ContextActions)
{
var flyoutItem = new MenuFlyoutItem();
flyoutItem.SetBinding(MenuFlyoutItem.TextProperty, "Text");
var flyoutItem = new Microsoft.UI.Xaml.Controls.MenuFlyoutItem();
flyoutItem.SetBinding(UI.Xaml.Controls.MenuFlyoutItem.TextProperty, "Text");
//WINUI FIX
//flyoutItem.Command = new MenuItemCommand(item);
flyoutItem.DataContext = item;
Expand Down
23 changes: 0 additions & 23 deletions src/Compatibility/Core/src/Windows/ElementExtensions.cs

This file was deleted.

52 changes: 52 additions & 0 deletions src/Controls/samples/Controls.Sample/Pages/Core/MenuBarPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Pages
{
public partial class MenuBarPage
{
public MenuBarPage()
{
InitializeComponent();
}

void ItemClicked(object sender, EventArgs e)
{
if (sender is MenuFlyoutItem mfi)
{
menuLabel.Text = $"You clicked on Menu Item: { mfi.Text}";
}
}

void ToggleMenuBarItem(object sender, EventArgs e)
{
MenuBarItem barItem =
MenuBarItems.FirstOrDefault(x => x.Text == "Added Menu");

if(barItem == null)
{
barItem = new MenuBarItem()
{
Text = "Added Menu"
};

barItem.Add(new MenuFlyoutItem()
{
Text = "Added Flyout Item",
Command = new Command(() => ItemClicked(barItem.First(), EventArgs.Empty))
});

MenuBarItems.Add(barItem);
}
else
{
MenuBarItems.Remove(barItem);
}
}
}
}
Loading

0 comments on commit cbace2d

Please sign in to comment.