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

Menu: changed MenuItem Header to type object #1294

Merged
merged 4 commits into from
Jul 12, 2017
Merged

Menu: changed MenuItem Header to type object #1294

merged 4 commits into from
Jul 12, 2017

Conversation

nmetulev
Copy link
Contributor

@nmetulev nmetulev commented Jul 5, 2017

re #1293, allows having other content than string inside a MenuItem

@nmetulev nmetulev added this to the v2.0 milestone Jul 5, 2017
@nmetulev nmetulev requested a review from IbraheemOsama July 5, 2017 21:32
@@ -38,16 +38,16 @@ public class MenuItem : ItemsControl
/// <summary>
/// Identifies the <see cref="Header"/> dependency property.
/// </summary>
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(string), typeof(MenuItem), new PropertyMetadata(default(string)));
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(object), typeof(MenuItem), new PropertyMetadata(null));
Copy link
Member

Choose a reason for hiding this comment

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

@nmetulev Why object instead of string ? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This way you can do something like

<controls:MenuItem Name="FileMenu"
                   controls:Menu.InputGestureText="Alt+F">
    <controls:MenuItem.Header>
        <StackPanel Orientation="Horizontal">
            <SymbolIcon Symbol="Accept"></SymbolIcon>
            <TextBlock Text="Hello"></TextBlock>
        </StackPanel>
    </controls:MenuItem.Header>
</controls:MenuItem>

Copy link
Member

Choose a reason for hiding this comment

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

Because of content is object, I looked through the code

Copy link
Contributor

@skendrot skendrot left a comment

Choose a reason for hiding this comment

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

Should have Header and HeaderTemplate

Copy link
Contributor

@skendrot skendrot left a comment

Choose a reason for hiding this comment

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

Why not just make it a ContentControl?

@IbraheemOsama
Copy link
Member

@skendrot we can't because it is already an ItemsControl

@skendrot
Copy link
Contributor

skendrot commented Jul 5, 2017

Good point!

@skendrot
Copy link
Contributor

skendrot commented Jul 5, 2017

Should still allow to override template

@IbraheemOsama
Copy link
Member

I agree, we need to add new property HeaderTemplate and bind it to the Button template in the menu

Copy link
Contributor

@skendrot skendrot left a comment

Choose a reason for hiding this comment

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

Should the Header be changed or add a property to show icons?

@IbraheemOsama
Copy link
Member

No icons please :) if he needs he can override.

@nmetulev
Copy link
Contributor Author

nmetulev commented Jul 6, 2017

IMO, The MenuItem can always be re-styled to change the header template.

@tibitoth
Copy link
Contributor

tibitoth commented Jul 6, 2017

Sorry I missed that MenuFlyoutItem has Icon property in #1293. MenuItem does not need to have Icon by default.

@IbraheemOsama
Copy link
Member

IbraheemOsama commented Jul 8, 2017

I'm with adding a header template :) can we merge this PR and will add it with my current PR ?

@skendrot
Copy link
Contributor

skendrot commented Jul 9, 2017

Header and HeaderTemplate go have in hand. Just like Content and ContentTemplate

@nmetulev
Copy link
Contributor Author

@IbraheemOsama, do you mind pushing the ContentTemplate to this PR, you should just be able to push to this branch?

@IbraheemOsama
Copy link
Member

@nmetulev sure, no problem at all, will push ContentTemplate to this branch.

@IbraheemOsama
Copy link
Member

@skendrot @nmetulev ping :)

public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register(nameof(HeaderTemplate), typeof(DataTemplate), typeof(MenuItem), new PropertyMetadata(null));

/// <summary>
/// Gets or sets the title to appear in the title bar
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be updated

@@ -52,6 +51,20 @@ public object Header
}

/// <summary>
/// Identifies the <see cref="Header"/> dependency property.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should point to HeaderTemplate (not Header)

@nmetulev
Copy link
Contributor Author

@IbraheemOsama, you are reading my mind cause you fixed it at the same time as I commented.

Looks good to me

@nmetulev nmetulev merged commit 0318d18 into dev Jul 12, 2017
@nmetulev nmetulev deleted the menuitemheader branch July 12, 2017 21:25
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.

5 participants