WinUI コントロール
Menu の要素
コントロール > Menu > Menu の要素

Menu supports adding icons to the menu items with a submenu which can be helpful in enhancing the appearance of the control. The C1MenuItem class provides Icon property that lets you set the icon for an item in the Menu control.

The following image shows the items of the Menu control with icons.

Menu items with icons

The following code showcases how to set icons for the items of the Menu. This example uses images as icons and these images are available in the MenuExplorer product sample.

XAML
コードのコピー
<c1:C1Menu x:Name="WordMenu" Orientation="Horizontal" VerticalAlignment="Top">
    <c1:C1MenuItem Header="File">
        <c1:C1MenuItem Header="New">
            <c1:C1MenuItem Header="Document">
                <c1:C1MenuItem.Icon>
                    <Image Source="../Resources/newFile.png"></Image>
                </c1:C1MenuItem.Icon>
            </c1:C1MenuItem>
            <c1:C1MenuItem Header="Project">
                <c1:C1MenuItem.Icon>
                    <Image Source="../Resources/newProject.png" />
                </c1:C1MenuItem.Icon>
            </c1:C1MenuItem>
        </c1:C1MenuItem>
        <c1:C1MenuItem Header="Open">
            <c1:C1MenuItem Header="Document">
                <c1:C1MenuItem.Icon>
                    <Image Source="../Resources/openFile.png" />
                </c1:C1MenuItem.Icon>
            </c1:C1MenuItem>
            <c1:C1MenuItem Header="Project">
                <c1:C1MenuItem.Icon>
                    <Image Source="../Resources/openProject.png" />
                </c1:C1MenuItem.Icon>
            </c1:C1MenuItem>
            <c1:C1MenuItem Header="Recent Document 1">
            </c1:C1MenuItem>
            <c1:C1MenuItem Header="Recent Document 2">
            </c1:C1MenuItem>
        </c1:C1MenuItem>
        <c1:C1MenuItem Header="Close Solution">
            <c1:C1MenuItem.Icon>
                <Image Source="../Resources/closeSolution.png" />
            </c1:C1MenuItem.Icon>
        </c1:C1MenuItem>
        <c1:C1MenuItem Header="Save">
            <c1:C1MenuItem.Icon>
                <Image Source="../Resources/save.png" />
            </c1:C1MenuItem.Icon>
        </c1:C1MenuItem>
        <c1:C1MenuItem Header="Exit"/>
    </c1:C1MenuItem>
    <c1:C1MenuItem Header="Edit">
        <c1:C1MenuItem Header="Undo">
            <c1:C1MenuItem.Icon>
                <Image Source="../Resources/undo.png" />
            </c1:C1MenuItem.Icon>
        </c1:C1MenuItem>
        <c1:C1MenuItem Header="Redo">
            <c1:C1MenuItem.Icon>
                <Image Source="../Resources/redo.png" />
            </c1:C1MenuItem.Icon>
        </c1:C1MenuItem>
    </c1:C1MenuItem>
    <c1:C1MenuItem Header="Build"></c1:C1MenuItem>
</c1:C1Menu>