-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
@@ -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)); |
There was a problem hiding this comment.
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 ? :)
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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
There was a problem hiding this 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
There was a problem hiding this 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?
@skendrot we can't because it is already an ItemsControl |
Good point! |
Should still allow to override template |
I agree, we need to add new property HeaderTemplate and bind it to the Button template in the menu |
There was a problem hiding this 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?
No icons please :) if he needs he can override. |
IMO, The MenuItem can always be re-styled to change the header template. |
Sorry I missed that MenuFlyoutItem has Icon property in #1293. MenuItem does not need to have Icon by default. |
I'm with adding a header template :) can we merge this PR and will add it with my current PR ? |
Header and HeaderTemplate go have in hand. Just like Content and ContentTemplate |
@IbraheemOsama, do you mind pushing the ContentTemplate to this PR, you should just be able to push to this branch? |
@nmetulev sure, no problem at all, will push ContentTemplate to this branch. |
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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)
@IbraheemOsama, you are reading my mind cause you fixed it at the same time as I commented. Looks good to me |
re #1293, allows having other content than string inside a MenuItem