Skip to content

Commit 8b13625

Browse files
authored
Merge pull request #1317 from Microsoft/revertinghamburgermenu
reverting back hamburgermenuitem
2 parents 367cd72 + f34dc52 commit 8b13625

File tree

7 files changed

+136
-75
lines changed

7 files changed

+136
-75
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HamburgerMenu/HamburgerMenuCode.bind

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,46 @@
88
xmlns:data="using:Microsoft.Toolkit.Uwp.SampleApp.Data"
99
mc:Ignorable="d">
1010

11+
<Page.Resources>
12+
<DataTemplate x:Key="HamburgerMenuItem" x:DataType="controls:HamburgerMenuGlyphItem">
13+
<Grid>
14+
<Grid.ColumnDefinitions>
15+
<ColumnDefinition Width="48" />
16+
<ColumnDefinition />
17+
</Grid.ColumnDefinitions>
18+
<FontIcon Grid.Column="0"
19+
FontFamily="Segoe MDL2 Assets"
20+
Glyph="{Binding Glyph}"
21+
Foreground="White" />
22+
<TextBlock Grid.Column="1"
23+
Text="{x:Bind Label}"
24+
Foreground="White"
25+
FontSize="16"
26+
VerticalAlignment="Center" />
27+
</Grid>
28+
</DataTemplate>
29+
30+
<DataTemplate x:Key="HamburgerMenuImageItem" x:DataType="controls:HamburgerMenuImageItem">
31+
<Grid>
32+
<Grid.ColumnDefinitions>
33+
<ColumnDefinition Width="48" />
34+
<ColumnDefinition />
35+
</Grid.ColumnDefinitions>
36+
<Image Source="{Binding Thumbnail}" Stretch="UniformToFill" Margin="16,12" />
37+
<TextBlock Grid.Column="1"
38+
Text="{x:Bind Label}"
39+
Foreground="White"
40+
FontSize="16"
41+
VerticalAlignment="Center" />
42+
</Grid>
43+
</DataTemplate>
44+
</Page.Resources>
45+
1146
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="50" BorderThickness="1" BorderBrush="Black">
1247
<controls:HamburgerMenu PaneBackground="@[PaneBackground:Brush:Black]" x:Name="HamburgerMenu"
1348
Foreground="White"
49+
ItemTemplate="{StaticResource HamburgerMenuImageItem}"
50+
OptionsItemTemplate="{StaticResource HamburgerMenuItem}"
1451
ItemClick="HamburgerMenu_OnItemClick"
1552
OptionsItemClick="HamburgerMenu_OnOptionsItemClick"
1653
OpenPaneLength="@[OpenPaneLength:Slider:240:50-400]"
@@ -22,14 +59,14 @@
2259
<!-- Items -->
2360
<controls:HamburgerMenu.ItemsSource>
2461
<controls:HamburgerMenuItemCollection>
25-
<controls:HamburgerMenuImageItem Thumbnail="ms-appx:///Assets/Photos/BigFourSummerHeat.jpg"
26-
Label="Big four summer heat" />
27-
<controls:HamburgerMenuImageItem Thumbnail="ms-appx:///Assets/Photos/BisonBadlandsChillin.jpg"
28-
Label="Bison badlands Chillin" />
29-
<controls:HamburgerMenuImageItem Thumbnail="ms-appx:///Assets/Photos/GiantSlabInOregon.jpg"
30-
Label="Giant slab in Oregon" />
31-
<controls:HamburgerMenuImageItem Thumbnail="ms-appx:///Assets/Photos/LakeAnnMushroom.jpg"
32-
Label="Lake Ann Mushroom" />
62+
<controls:HamburgerMenuImageItem Label="Big four summer heat"
63+
Thumbnail="/Assets/Photos/BigFourSummerHeat.jpg"/>
64+
<controls:HamburgerMenuImageItem Label="Bison badlands Chillin"
65+
Thumbnail="/Assets/Photos/BisonBadlandsChillin.jpg"/>
66+
<controls:HamburgerMenuImageItem Label="Giant slab in Oregon"
67+
Thumbnail="/Assets/Photos/GiantSlabInOregon.jpg"/>
68+
<controls:HamburgerMenuImageItem Label="Lake Ann Mushroom"
69+
Thumbnail="/Assets/Photos/LakeAnnMushroom.jpg"/>
3370
</controls:HamburgerMenuItemCollection>
3471
</controls:HamburgerMenu.ItemsSource>
3572

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HamburgerMenu/HamburgerMenuPage.xaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,52 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
mc:Ignorable="d">
8+
9+
<Page.Resources>
10+
<DataTemplate x:Key="HamburgerMenuItem" x:DataType="controls:HamburgerMenuGlyphItem">
11+
<Grid>
12+
<Grid.ColumnDefinitions>
13+
<ColumnDefinition Width="48" />
14+
<ColumnDefinition />
15+
</Grid.ColumnDefinitions>
16+
<FontIcon Grid.Column="0"
17+
FontFamily="Segoe MDL2 Assets"
18+
Glyph="{Binding Glyph}"
19+
Foreground="White" />
20+
<TextBlock Grid.Column="1"
21+
Text="{x:Bind Label}"
22+
Foreground="White"
23+
FontSize="16"
24+
VerticalAlignment="Center" />
25+
</Grid>
26+
</DataTemplate>
27+
28+
<DataTemplate x:Key="HamburgerMenuImageItem" x:DataType="controls:HamburgerMenuImageItem">
29+
<Grid>
30+
<Grid.ColumnDefinitions>
31+
<ColumnDefinition Width="48" />
32+
<ColumnDefinition />
33+
</Grid.ColumnDefinitions>
34+
<Image Source="{Binding Thumbnail}"
35+
Stretch="UniformToFill"
36+
Margin="16,12" />
37+
<TextBlock Grid.Column="1"
38+
Text="{x:Bind Label}"
39+
Foreground="White"
40+
FontSize="16"
41+
VerticalAlignment="Center" />
42+
</Grid>
43+
</DataTemplate>
44+
</Page.Resources>
45+
846
<Grid Padding="50"
947
Background="{StaticResource Brush-Grey-05}">
1048
<controls:HamburgerMenu x:Name="HamburgerMenuControl"
1149
CompactPaneLength="{Binding CompactPaneLength.Value}"
1250
DisplayMode="{Binding DisplayMode.Value}"
1351
Foreground="White"
52+
ItemTemplate="{StaticResource HamburgerMenuImageItem}"
53+
OptionsItemTemplate="{StaticResource HamburgerMenuItem}"
1454
HamburgerHeight="{Binding HamburgerHeight.Value}"
1555
HamburgerVisibility="{Binding HamburgerVisibility.Value}"
1656
HamburgerWidth="48"

Microsoft.Toolkit.Uwp.SampleApp/Shell.xaml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,39 @@
1919
<Page.Resources>
2020
<DataTemplate x:Key="ButtonTemplate"
2121
x:DataType="local:SampleCategory">
22-
<controls:HamburgerMenuImageItem Thumbnail="{x:Bind Icon}" Label="{x:Bind Name}"/>
22+
<Grid>
23+
<Grid.ColumnDefinitions>
24+
<ColumnDefinition Width="48" />
25+
<ColumnDefinition />
26+
</Grid.ColumnDefinitions>
27+
<Image Margin="16,12"
28+
Source="{x:Bind Icon}"
29+
Stretch="Uniform" />
30+
<TextBlock Grid.Column="1"
31+
VerticalAlignment="Center"
32+
FontSize="16"
33+
Foreground="White"
34+
Text="{x:Bind Name}" />
35+
</Grid>
2336
</DataTemplate>
2437

2538
<DataTemplate x:Key="OptionTemplate"
2639
x:DataType="local:Option">
27-
<controls:HamburgerMenuGlyphItem Glyph="{x:Bind Glyph}" Label="{x:Bind Name}"/>
40+
<Grid>
41+
<Grid.ColumnDefinitions>
42+
<ColumnDefinition Width="48" />
43+
<ColumnDefinition />
44+
</Grid.ColumnDefinitions>
45+
<FontIcon Grid.Column="0"
46+
FontFamily="Segoe MDL2 Assets"
47+
Foreground="White"
48+
Glyph="{x:Bind Glyph}"/>
49+
<TextBlock Grid.Column="1"
50+
VerticalAlignment="Center"
51+
FontSize="16"
52+
Foreground="White"
53+
Text="{x:Bind Name}" />
54+
</Grid>
2855
</DataTemplate>
2956

3057
</Page.Resources>

Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu/HamburgerMenu.xaml

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,6 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
44

5-
<Style TargetType="local:HamburgerMenuGlyphItem">
6-
<Setter Property="Template">
7-
<Setter.Value>
8-
<ControlTemplate TargetType="local:HamburgerMenuGlyphItem">
9-
<Grid>
10-
<Grid.ColumnDefinitions>
11-
<ColumnDefinition Width="48" />
12-
<ColumnDefinition />
13-
</Grid.ColumnDefinitions>
14-
<FontIcon FontFamily="Segoe MDL2 Assets"
15-
FontSize="16"
16-
Foreground="White"
17-
Glyph="{TemplateBinding Glyph}"
18-
Margin="16,12"/>
19-
<TextBlock FontSize="16"
20-
Foreground="White"
21-
Grid.Column="1"
22-
Text="{TemplateBinding Label}"
23-
VerticalAlignment="Center"/>
24-
</Grid>
25-
</ControlTemplate>
26-
</Setter.Value>
27-
</Setter>
28-
</Style>
29-
30-
<Style TargetType="local:HamburgerMenuImageItem">
31-
<Setter Property="Template">
32-
<Setter.Value>
33-
<ControlTemplate TargetType="local:HamburgerMenuImageItem">
34-
<Grid>
35-
<Grid.ColumnDefinitions>
36-
<ColumnDefinition Width="48" />
37-
<ColumnDefinition />
38-
</Grid.ColumnDefinitions>
39-
<Image Margin="16,12"
40-
Source="{TemplateBinding Thumbnail}"
41-
Stretch="UniformToFill"/>
42-
<TextBlock FontSize="16"
43-
Foreground="White"
44-
Grid.Column="1"
45-
Text="{TemplateBinding Label}"
46-
VerticalAlignment="Center"/>
47-
</Grid>
48-
</ControlTemplate>
49-
</Setter.Value>
50-
</Setter>
51-
</Style>
52-
535
<Style x:Key="HambugerMenuItemStyle" TargetType="ListViewItem">
546
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
557
<Setter Property="Background" Value="Transparent" />

Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu/MenuItems/HamburgerMenuGlyphItem.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ public class HamburgerMenuGlyphItem : HamburgerMenuItem
2424
/// </summary>
2525
public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register(nameof(Glyph), typeof(string), typeof(HamburgerMenuItem), new PropertyMetadata(null));
2626

27-
/// <summary>
28-
/// Initializes a new instance of the <see cref="HamburgerMenuGlyphItem"/> class.
29-
/// </summary>
30-
public HamburgerMenuGlyphItem()
31-
{
32-
DefaultStyleKey = typeof(HamburgerMenuGlyphItem);
33-
}
34-
3527
/// <summary>
3628
/// Gets or sets a value that specifies the glyph to use from Segoe MDL2 Assets font.
3729
/// </summary>

Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu/MenuItems/HamburgerMenuImageItem.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ public class HamburgerMenuImageItem : HamburgerMenuItem
2626
/// </summary>
2727
public static readonly DependencyProperty ThumbnailProperty = DependencyProperty.Register(nameof(Thumbnail), typeof(ImageSource), typeof(HamburgerMenuItem), new PropertyMetadata(null));
2828

29-
/// <summary>
30-
/// Initializes a new instance of the <see cref="HamburgerMenuImageItem"/> class.
31-
/// </summary>
32-
public HamburgerMenuImageItem()
33-
{
34-
DefaultStyleKey = typeof(HamburgerMenuImageItem);
35-
}
36-
3729
/// <summary>
3830
/// Gets or sets a value that specifies a bitmap to display with an Image control.
3931
/// </summary>

Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu/MenuItems/HamburgerMenuItem.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
1919
/// <summary>
2020
/// The HamburgerMenuItem provides an abstract implementation for HamburgerMenu entries.
2121
/// </summary>
22-
public abstract class HamburgerMenuItem : Control
22+
public abstract class HamburgerMenuItem : DependencyObject
2323
{
2424
/// <summary>
2525
/// Identifies the <see cref="Label"/> dependency property.
@@ -31,6 +31,11 @@ public abstract class HamburgerMenuItem : Control
3131
/// </summary>
3232
public static readonly DependencyProperty TargetPageTypeProperty = DependencyProperty.Register(nameof(TargetPageType), typeof(Type), typeof(HamburgerMenuItem), new PropertyMetadata(null));
3333

34+
/// <summary>
35+
/// Identifies the <see cref="Tag"/> dependency property.
36+
/// </summary>
37+
public static readonly DependencyProperty TagProperty = DependencyProperty.Register(nameof(Tag), typeof(object), typeof(HamburgerMenuItem), new PropertyMetadata(null));
38+
3439
/// <summary>
3540
/// Gets or sets a value that specifies label to display.
3641
/// </summary>
@@ -62,5 +67,21 @@ public Type TargetPageType
6267
SetValue(TargetPageTypeProperty, value);
6368
}
6469
}
70+
71+
/// <summary>
72+
/// Gets or sets a value that specifies an user specific value.
73+
/// </summary>
74+
public object Tag
75+
{
76+
get
77+
{
78+
return GetValue(TagProperty);
79+
}
80+
81+
set
82+
{
83+
SetValue(TagProperty, value);
84+
}
85+
}
6586
}
6687
}

0 commit comments

Comments
 (0)