Skip to content

Conversation

@nmetulev
Copy link
Contributor

@nmetulev nmetulev commented Jul 4, 2017

No description provided.

@nmetulev nmetulev requested a review from IbraheemOsama July 4, 2017 00:14

if (!_menuFlyoutRepositioned)
{
var item = _menuFlyout.Items.First();
Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible for a menu to not have any items

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the dependency on Items completely

VisualStateManager.GoToState(this, "Opened", true);
_parentMenu.IsInTransitionState = false;

if (!_menuFlyoutRepositioned)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is opened called multiple times in a row? Why check when for this variable when it's set to false on close?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the first time when checking if it should be re positioned, and the second time if it's being shown re positioned

@IbraheemOsama
Copy link
Member

@nmetulev if you used the following xaml code you'll receive an exception
`

<Page.Resources>
    <ResourceDictionary>
        <commands:NewProjectCommand x:Key="NewProject" />
        <commands:NewFileCommand x:Key="NewFile" />
        <commands:GenericCommand x:Key="GenericCommand" />
    </ResourceDictionary>
</Page.Resources>

<Grid Background="{StaticResource Brush-Grey-05}">
    <!--<Grid.RowDefinitions>
        <RowDefinition Height="auto" />
        <RowDefinition Height="auto" />
    </Grid.RowDefinitions>-->

    <controls:Menu VerticalAlignment="Bottom"
                   AllowTooltip="{Binding AllowTooltip.Value, Mode=TwoWay}"
                   Orientation="{Binding Orientation.Value, Mode=TwoWay}"
                   TooltipPlacement="{Binding TooltipPlacement.Value, Mode=TwoWay}">

        <controls:MenuItem Name="FileMenu"
                           controls:Menu.InputGestureText="Alt+F"
                           Header="File">
            <MenuFlyoutSubItem Text="New">
                <MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+N"
                                Command="{StaticResource NewProject}"
                                Text="Project" />
                <MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+N"
                                Command="{StaticResource NewFile}"
                                Text="File" />
            </MenuFlyoutSubItem>
            <MenuFlyoutSubItem Text="Open">
                <MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+O"
                                Command="{StaticResource GenericCommand}"
                                CommandParameter="Select Project/Solution"
                                Text="Project/Solution" />
                <MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+O"
                                Command="{StaticResource GenericCommand}"
                                CommandParameter="Select File"
                                Text="File" />
            </MenuFlyoutSubItem>
            <MenuFlyoutSeparator />
            <MenuFlyoutItem Text="Page Setup" />
            <MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+P"
                            Command="{StaticResource GenericCommand}"
                            CommandParameter="Page is Printed!!"
                            Text="Print" />
            <MenuFlyoutSeparator />
            <MenuFlyoutSubItem Text="Recent Files">
                <MenuFlyoutItem Text="UWP ToolKit GridSplitter" />
                <MenuFlyoutItem Text="UWP ToolKit WrapPanel" />
            </MenuFlyoutSubItem>
            <MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+E"
                            Command="{StaticResource GenericCommand}"
                            CommandParameter="Solution closed"
                            Text="Exit" />
        </controls:MenuItem>


        <controls:MenuItem controls:Menu.InputGestureText="Alt+E"
                           Header="Edit">
            <MenuFlyoutSubItem Text="Go To">
                <MenuFlyoutItem Text="Go To Line" />
                <MenuFlyoutItem Text="Go To All" />
            </MenuFlyoutSubItem>

            <MenuFlyoutSubItem Text="Find and Replace">
                <MenuFlyoutItem Text="Find" />
                <MenuFlyoutItem Text="Replace" />
            </MenuFlyoutSubItem>
        </controls:MenuItem>

        <controls:MenuItem controls:Menu.InputGestureText="Alt+V"
                           Header="View">
            <MenuFlyoutSubItem Text="Designer">
                <MenuFlyoutItem Text="VS Designer" />
                <MenuFlyoutItem Text="Blend" />
            </MenuFlyoutSubItem>

            <MenuFlyoutSubItem Text="Solution Explorer">
                <MenuFlyoutItem Text="Solutions" />
                <MenuFlyoutItem Text="Projects" />
            </MenuFlyoutSubItem>
        </controls:MenuItem>

        <controls:MenuItem controls:Menu.InputGestureText="Alt+P"
                           Header="Project">
            <MenuFlyoutSubItem Text="Add Class">
                <MenuFlyoutItem Text="Class" />
                <MenuFlyoutItem Text="Interface" />
            </MenuFlyoutSubItem>

            <MenuFlyoutSubItem Text="Add new data source">
                <MenuFlyoutItem Text="SQL" />
                <MenuFlyoutItem Text="NoSQL" />
            </MenuFlyoutSubItem>
        </controls:MenuItem>

        <controls:MenuItem controls:Menu.InputGestureText="Alt+B"
                           Header="Build">
            <MenuFlyoutItem Text="Build Solution" />
            <MenuFlyoutItem Text="Rebuild Solution" />
        </controls:MenuItem>

        <controls:MenuItem controls:Menu.InputGestureText="Alt+D"
                           Header="Debug">
            <MenuFlyoutSubItem Text="Windows">
                <MenuFlyoutItem Text="Windows 8" />
                <MenuFlyoutItem Text="Windows 10" />
            </MenuFlyoutSubItem>

            <MenuFlyoutSubItem Text="Graphics">
                <MenuFlyoutItem Text="Canvas" />
                <MenuFlyoutItem Text="Grid" />
            </MenuFlyoutSubItem>
        </controls:MenuItem>

    </controls:Menu>

    <!--<StackPanel Grid.Row="1">
        <TextBlock Text="Click Alt to set focus on Classic Menu" />
        <TextBlock Text="Any menu shortcut is Alt + (The first character of the menu name), ex to open File menu click Alt+F" />
        <TextBlock Text="Create new project shortcut: Ctrl+Shift+N" />
        <TextBlock Text="Create new file shortcut: Ctrl+N" />
        <TextBlock Text="Open project shortcut: Ctrl+Shift+O" />
        <TextBlock Text="Open file shortcut: Ctrl+O" />
        <TextBlock Text="Print shortcut: Ctrl+P" />
        <TextBlock Text="Exit solution shortcut: Ctrl+Shit+E" />
    </StackPanel>-->

</Grid>

`
image

click edit and you wil get
image

Will fork your repo and try to expose menu placement property and adding some validations

@IbraheemOsama
Copy link
Member

Closed for sake of another PR that has same commits. I just couldn't push on Nikola branch. new branch is #1285

@nmetulev nmetulev deleted the menuitemLocationFix branch September 1, 2017 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants