Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RadioMenuFlyoutItem API review #19

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
67 changes: 67 additions & 0 deletions active/RadioMenuFlyoutItem/RadioMenuFlyoutItem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Background
A [MenuFlyoutItem](https://docs.microsoft.com/uwp/api/Windows.UI.Xaml.Controls.MenuFlyoutItem) is an item
in a menu, be it a context menu ([MenuFlyout](https://docs.microsoft.com/uwp/api/Windows.UI.Xaml.Controls.MenuFlyout))
or a [MenuBarItem](https://docs.microsoft.com/uwp/api/Windows.UI.Xaml.Controls.MenuBarItem).

The new RadioMenuFlyoutItem in this spec is a MenuFlyoutItem that displays and behaves like a radio button
(can be checked/unchecked, and in a group only one is selected at a time).

# Description
A radio menu flyout item is a menu item that is mutually exclusive with other radio menu items in its group.
This control contol allows you to present users with menus containing multiple options, where a user would choose only one of these options at a given time.


# Examples

## Create RadioMenuFlyoutItems
*RadioMenuFlyoutItem* can be added into a *MenuBarItem*, *MenuFlyout*, or *MenuFlyoutSubItem*. The following example shows three radio menu flyout items as the content of a cascading menu flyout.

![Three radio menu flyout items in a View goup that allow a user to select the size of icons](RadioMenuFlyoutItem.png)

````Xaml
<MenuFlyout>
<MenuFlyoutSubItem Text="View">
<muxc:RadioMenuFlyoutItem Text="Small icons"/>
<muxc:RadioMenuFlyoutItem Text="Medium icons" IsChecked="True"/>
<muxc:RadioMenuFlyoutItem Text="Large icons"/>
</MenuFlyoutSubItem>
</MenuFlyout>
````

## Group RadioMenuFlyoutItem into multiple sets
Radio menu flyout items work in groups, and users can only select one item in a radio menu flyout item group. To create multiple groups of radio buttons within a single menu, be sure to specify the `GroupName` property of each set.

![Two groups of radio menu flyout items within a View menu bar item](RadioMenuFlyoutItem2.png)

````Xaml
<muxc:MenuBar>
<muxc:MenuBarItem Title="View">
<MenuFlyoutItem Text="Open"/>
<MenuFlyoutSeparator/>
<muxc:RadioMenuFlyoutItem Text="Landscape" GroupName="OrientationGroup"/>
<muxc:RadioMenuFlyoutItem Text="Portrait" GroupName="OrientationGroup" IsChecked="True"/>
<MenuFlyoutSeparator/>
<muxc:RadioMenuFlyoutItem Text="Small icons" GroupName="SizeGroup"/>
<muxc:RadioMenuFlyoutItem Text="Medium icons" IsChecked="True" GroupName="SizeGroup"/>
<muxc:RadioMenuFlyoutItem Text="Large icons" GroupName="SizeGroup"/>
</muxc:MenuBarItem>
</muxc:MenuBar>
````

# API Details
````c#
[webhosthidden]
unsealed runtimeclass RadioMenuFlyoutItem : Windows.UI.Xaml.Controls.MenuFlyoutItem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RadioButton derives from ToggleButton, but RadioMenuFlyoutItem doesn't derive from ToggleMenuFlyoutItem. Intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did do that intentionally but I could be convinced otherwise. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does/should it support ThreeState?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should, that doesn't feel like a compelling scenario inside a context menu.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: Based on that, not deriving from ToggleMenuFlyoutItem sounds right.

{
RadioMenuFlyoutItem();

/// Gets or sets whether the RadioMenuFlyoutItem is checked
Boolean IsChecked;

/// Gets or sets the name that specifies which RadioMenuFlyoutItem controls are mutually exclusive
String GroupName;
Copy link
Member

@oldnewthing oldnewthing Mar 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the GroupName scope is the containing MenuFlyout? Or is it scoped to the MenuFlyoutSubItem if in a subitem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's scoped to siblings in whatever flyout it's in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend: Need to update this in the description.


static Windows.UI.Xaml.DependencyProperty IsCheckedProperty{ get; };
static Windows.UI.Xaml.DependencyProperty GroupNameProperty{ get; };
}
````
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.