AlterNET UI Beta 3 - Menus, keyboard shortcuts, modal windows and more

AlterNET UI Beta 3 adds essential features like menus, keyboard shortcuts, commands, modal windows, advanced window management, and more.

Menus 

MainMenuMenu, and MenuItem classes allow you to build complex menu hierarchies from UIXML or code. These menus support macOS system UI guidelines, including automatically moving items like "About" or "Quit" to the macOS application menu. Developers can override this behavior by setting MenuItem.Role property.

The menu capabilities are demonstrated in the new MenuSample demo project.

Keyboard Shortcuts

Related to menus is the keyboard shortcuts support. Developers can specify the shortcuts like "Ctrl+O" or "Shift+F1" for menu items directly from UIXML. Shortcut modifier keys get automatically translated to the platform-specific shortcuts. For example, Control + C is translated to Cmd+C on macOS, so most of the shortcuts can be specified once for all the platforms. Developers can also set the modifier keys specifically for macOS.

Commands

Commands allow separating the semantics and the object that invokes a command from the logic that executes the command. Another purpose of commands is to indicate whether an action is available. The programmer can set MenuItem.Command property to link an ICommand with a MenuItem. As the command can be data-bound from UIXML, this follows the MVVM approach of implementing user interfaces.

Modal Windows and Window Management

Developers can now show a window modally by calling the Window.ShowModal method. A ModalResult is then returned to indicate the result with which a modal dialog window is closed.

In this release, we added more features allowing you to control application windows, most of them as members of the Window class. You can now change window ownership, state, activation, title bar, border features, icons, and window bounds.

The newly added WindowPropertiesSample demo project shows these new window management capabilities.

Sample below shows how to define a menu in the AlterNET UI project:

Code


public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void OpenMenuItem_Click(object sender, EventArgs e) => MessageBox.Show("Open");

    private void HelpMenuItem_Click(object sender, EventArgs e) => aboutBox.ShowModal();
}

UIXML

<Window.Menu>
  <MainMenu>
    <MenuItem Text="_File">
      <MenuItem Text="_Open..." Name="openMenuItem" Click="OpenMenuItem_Click" Shortcut="Ctrl+O"/>
    </MenuItem>
    <MenuItem Text="_Help">
      <MenuItem Text="_About..." Name="helpMenuItem" Click="HelpMenuItem_Click" Shortcut="Shift+F1"/>
    </MenuItem>
  </MainMenu>
</Window.Menu>

Subscribe to our newsletter and stay tuned for more AlterNET UI news.

Previous
Previous

AlterNET UI Beta 4 - What you see is what you get

Next
Next

AlterNET UI Beta 2 - Layout system, dependency property, data binding, and more