Skip to content

Commit 99bbee9

Browse files
timuniepunker76
authored andcommitted
Badged Example
1 parent 175faaf commit 99bbee9

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<UserControl x:Class="MahApps.Demo.ExampleViews.BadgedExample"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:ctrls="clr-namespace:MahApps.Demo.Controls"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MahApps.Demo.ExampleViews"
7+
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
d:DesignHeight="450"
10+
d:DesignWidth="800"
11+
mc:Ignorable="d">
12+
<ctrls:DemoView x:Name="demoView"
13+
xml:space="preserve"
14+
HyperlinkOnlineDocs="https://mahapps.com/docs/controls/badgedcontrol">
15+
<ctrls:DemoView.ExampleXaml><![CDATA[<mah:Badged x:Name="badge" Badge="1">
16+
<Button Margin="5"
17+
HorizontalAlignment="Stretch"
18+
VerticalAlignment="Center"
19+
Click="Button_Click"
20+
Content="Click Me"
21+
IsEnabled="True" />
22+
</mah:Badged> ]]>
23+
</ctrls:DemoView.ExampleXaml>
24+
<mah:Badged x:Name="badge" Badge="1"
25+
VerticalAlignment="Center"
26+
HorizontalAlignment="Stretch"
27+
Margin="20">
28+
<Button Margin="5" xml:space="preserve"
29+
HorizontalAlignment="Stretch"
30+
VerticalAlignment="Center"
31+
Click="Button_Click"
32+
MouseRightButtonUp="Button_MouseRightButtonUp"
33+
IsEnabled="True" >Click to increase
34+
Rightclick to clear</Button>
35+
</mah:Badged>
36+
</ctrls:DemoView>
37+
</UserControl>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using MahApps.Demo.Controls;
2+
using MahApps.Metro.Controls;
3+
using MahApps.Metro.Demo_v2;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows;
10+
using System.Windows.Controls;
11+
using System.Windows.Data;
12+
using System.Windows.Documents;
13+
using System.Windows.Input;
14+
using System.Windows.Media;
15+
using System.Windows.Media.Imaging;
16+
using System.Windows.Navigation;
17+
using System.Windows.Shapes;
18+
19+
namespace MahApps.Demo.ExampleViews
20+
{
21+
/// <summary>
22+
/// Interaction logic for BadgedExample.xaml
23+
/// </summary>
24+
public partial class BadgedExample : UserControl
25+
{
26+
public BadgedExample()
27+
{
28+
InitializeComponent();
29+
30+
demoView.DemoProperties.Add(new DemoViewProperty(Badged.BadgeProperty, badge, "Badged"));
31+
}
32+
33+
private void Button_Click(object sender, RoutedEventArgs e)
34+
{
35+
badge.SetCurrentValue(ControlzEx.BadgedEx.BadgeProperty, (badge.Badge as int? ?? 0) + 1);
36+
}
37+
38+
private void Button_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
39+
{
40+
badge.SetCurrentValue(ControlzEx.BadgedEx.BadgeProperty, null);
41+
}
42+
}
43+
}

src/MahApps.Metro.Demo_v2/MainWindow.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,20 @@
4444

4545
<mah:HamburgerMenu.ItemsSource>
4646
<mah:HamburgerMenuItemCollection>
47+
48+
<mah:HamburgerMenuHeaderItem Label="Controls" />
49+
4750
<mah:HamburgerMenuIconItem Icon="{iconPacks:Material Kind=Counter, Width=20, Height=20}" Label="NumericUpDown">
4851
<mah:HamburgerMenuIconItem.Tag>
4952
<views:NumericUpDownExample />
5053
</mah:HamburgerMenuIconItem.Tag>
5154
</mah:HamburgerMenuIconItem>
55+
56+
<mah:HamburgerMenuIconItem Icon="{iconPacks:Material Kind=PoliceBadge, Width=20, Height=20}" Label="Badged">
57+
<mah:HamburgerMenuIconItem.Tag>
58+
<views:BadgedExample />
59+
</mah:HamburgerMenuIconItem.Tag>
60+
</mah:HamburgerMenuIconItem>
5261

5362
<mah:HamburgerMenuSeparatorItem />
5463
<mah:HamburgerMenuHeaderItem Label="Styles" />

0 commit comments

Comments
 (0)