timheuer / callisto

A control toolkit for Windows 8 XAML applications. Contains some UI controls to make it easier to create Windows UI style apps for the Windows Store in accordance with Windows UI guidelines.
http://timheuer.com/blog/archive/2012/05/31/introducing-callisto-a-xaml-toolkit-for-metro-apps.aspx
Other
338 stars 108 forks source link

Menu click handler assumes Menu is directly nested inside Flyout #57

Closed yavorg closed 12 years ago

yavorg commented 12 years ago

The click handler on Menu will fail if the Menu not nested directly in the Content property of Flyout. I want to add some other things inside the Flyout (a search box) other than the Menu, so I use a StackPanel as the Content property and then nest the Menu inside.

        void OnMenuItemSelected(object sender, TappedRoutedEventArgs args)
        {
            MenuItem item = sender as MenuItem;

            if (item == null)
                return;

            ((Flyout)this.Parent).IsOpen = false;

            if (item.Command != null)
                item.Command.Execute(item.CommandParameter);
        }
timheuer commented 12 years ago

Can you use a regular fly out for that? The menu is meant strictly for menu commands only (per guidelines)

On Monday, July 9, 2012, Yavor Georgiev wrote:

The click handler on Menu will fail if the Menu not nested directly in the Content property of Flyout. I want to add some other things inside the Flyout (a search box) other than the Menu, so I use a StackPanel as the Content property and then nest the Menu inside.

        void OnMenuItemSelected(object sender, TappedRoutedEventArgs args)
        {
            MenuItem item = sender as MenuItem;

            if (item == null)
                return;

            ((Flyout)this.Parent).IsOpen = false;

            if (item.Command != null)
                item.Command.Execute(item.CommandParameter);
        }

Reply to this email directly or view it on GitHub: https://github.com/timheuer/callisto/issues/57


http://timheuer.com/blog/ twitter: @timheuer

yavorg commented 12 years ago

I'm not sure I understand. All I want is a Flyout with some text (like "Please pick an item from the menu below") followed by the menu itself. The menu itself is plain, there's nothing fancy in it.

timheuer commented 12 years ago

But are you using my Menu control? If so, that is designed only for menu item content (text) and not input.

Perhaps xaml of what you are trying?

On Tuesday, July 10, 2012, Yavor Georgiev wrote:

I'm not sure I understand. All I want is a Flyout with some text (like "Please pick an item from the menu below") followed by the menu itself. The menu itself is plain, there's nothing fancy in it.


Reply to this email directly or view it on GitHub: https://github.com/timheuer/callisto/issues/57#issuecomment-6896499


http://timheuer.com/blog/ twitter: @timheuer

yavorg commented 12 years ago

I am using your Menu control inside your Flyout. There is no text input anywhere in the whole arrangement. I don't have the code, but the structure is this

Flyout.Content = StackPanel

The problem is that the Menu assumes its parent is always Flyout, because it wants to close the Flyout it is nested into when the user clicks a menu item. In this case it would fail because the parent is a StackPanel. If I were to suggest a fix, it would be for Menu to crawl its parent chain and find the first Flyout and close that.

timheuer commented 12 years ago

Yes there is the problem...Menu is intended to be used on it's own. It is a Menu flyout itself designed only to meet the UI guidelines of Menu for Metro apps. So using it within another flyout or mixed with other UI elements isn't supported.


http://timheuer.com/blog/ twitter: @timheuer

On Wed, Jul 11, 2012 at 2:35 PM, Yavor Georgiev < reply@reply.github.com

wrote:

I am using your Menu control inside your Flyout. There is no text input anywhere in the whole arrangement. I don't have the code, but the structure is this

Flyout.Content = StackPanel

  • TextBlock
  • Menu

The problem is that the Menu assumes its parent is always Flyout, because it wants to close the Flyout it is nested into when the user clicks a menu item. In this case it would fail because the parent is a StackPanel. If I were to suggest a fix, it would be for Menu to crawl its parent chain and find the first Flyout and close that.


Reply to this email directly or view it on GitHub: https://github.com/timheuer/callisto/issues/57#issuecomment-6920491

yavorg commented 12 years ago

Sure, guidelines are guidelines I guess. From a practical developer point of view, I don't think what I'm doing is that ungodly, so I expect other folks to run into it as well.

timheuer commented 12 years ago

Not saying you can't do it, just that my Menu control wasn't designed to be hosted within another element.

On Wednesday, July 11, 2012, Yavor Georgiev wrote:

Sure, guidelines are guidelines I guess. From a practical developer point of view, I don't think what I'm doing is that ungodly, so I expect other folks to run into it as well.


Reply to this email directly or view it on GitHub: https://github.com/timheuer/callisto/issues/57#issuecomment-6922358


http://timheuer.com/blog/ twitter: @timheuer