Skip to content

Commit 6fc0d12

Browse files
committed
start of chip stuff
1 parent dd18568 commit 6fc0d12

File tree

7 files changed

+120
-0
lines changed

7 files changed

+120
-0
lines changed

MainDemo.Wpf/Chips.xaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<UserControl x:Class="MaterialDesignColors.WpfExample.Chips"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MaterialDesignColors.WpfExample"
7+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
8+
mc:Ignorable="d"
9+
d:DesignHeight="300" d:DesignWidth="300">
10+
<Grid Margin="32">
11+
<materialDesign:Chip Text="Butcher's Boy" />
12+
</Grid>
13+
</UserControl>

MainDemo.Wpf/Chips.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MaterialDesignColors.WpfExample
17+
{
18+
/// <summary>
19+
/// Interaction logic for Chips.xaml
20+
/// </summary>
21+
public partial class Chips : UserControl
22+
{
23+
public Chips()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

MainDemo.Wpf/MainDemo.Wpf.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
<Compile Include="Cards.xaml.cs">
7676
<DependentUpon>Cards.xaml</DependentUpon>
7777
</Compile>
78+
<Compile Include="Chips.xaml.cs">
79+
<DependentUpon>Chips.xaml</DependentUpon>
80+
</Compile>
7881
<Compile Include="ColorZones.xaml.cs">
7982
<DependentUpon>ColorZones.xaml</DependentUpon>
8083
</Compile>
@@ -154,6 +157,10 @@
154157
<SubType>Designer</SubType>
155158
<Generator>MSBuild:Compile</Generator>
156159
</Page>
160+
<Page Include="Chips.xaml">
161+
<SubType>Designer</SubType>
162+
<Generator>MSBuild:Compile</Generator>
163+
</Page>
157164
<Page Include="ColorZones.xaml">
158165
<SubType>Designer</SubType>
159166
<Generator>MSBuild:Compile</Generator>

MainDemo.Wpf/MainWindow.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@
9595
<wpfExample:Cards />
9696
</domain:DemoItem.Content>
9797
</domain:DemoItem>
98+
<domain:DemoItem Name="Chips">
99+
<domain:DemoItem.Content>
100+
<wpfExample:Chips />
101+
</domain:DemoItem.Content>
102+
</domain:DemoItem>
98103
<domain:DemoItem Name="Colour Zones">
99104
<domain:DemoItem.Content>
100105
<wpfExample:ColorZones />

MaterialDesignThemes.Wpf/Chip.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
9+
namespace MaterialDesignThemes.Wpf
10+
{
11+
public class Chip : Control
12+
{
13+
static Chip()
14+
{
15+
DefaultStyleKeyProperty.OverrideMetadata(typeof(Chip), new FrameworkPropertyMetadata(typeof(Chip)));
16+
}
17+
18+
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
19+
"Icon", typeof (object), typeof (Chip), new PropertyMetadata(default(object)));
20+
21+
public object Icon
22+
{
23+
get { return (object) GetValue(IconProperty); }
24+
set { SetValue(IconProperty, value); }
25+
}
26+
27+
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
28+
"Text", typeof (string), typeof (Chip), new PropertyMetadata(default(string)));
29+
30+
public string Text
31+
{
32+
get { return (string) GetValue(TextProperty); }
33+
set { SetValue(TextProperty, value); }
34+
}
35+
36+
public static readonly DependencyProperty IsDeletableProperty = DependencyProperty.Register(
37+
"IsDeletable", typeof (bool), typeof (Chip), new PropertyMetadata(default(bool)));
38+
39+
public bool IsDeletable
40+
{
41+
get { return (bool) GetValue(IsDeletableProperty); }
42+
set { SetValue(IsDeletableProperty, value); }
43+
}
44+
}
45+
}

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
</ItemGroup>
208208
<ItemGroup>
209209
<Compile Include="Card.cs" />
210+
<Compile Include="Chip.cs" />
210211
<Compile Include="Clock.cs" />
211212
<Compile Include="ClockChoiceMadeEventArgs.cs" />
212213
<Compile Include="ClockItemButton.cs" />

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,27 @@
366366
</Setter.Value>
367367
</Setter>
368368
</Style>
369+
370+
<Style TargetType="{x:Type local:Chip}">
371+
<Setter Property="Height" Value="32" />
372+
<Setter Property="HorizontalAlignment" Value="Left" />
373+
<Setter Property="Template">
374+
<Setter.Value>
375+
<ControlTemplate TargetType="{x:Type local:Chip}">
376+
<Grid>
377+
<Border CornerRadius="16" Background="#12000000"></Border>
378+
<TextBlock Text="{TemplateBinding Text}"
379+
VerticalAlignment="Center"
380+
Margin="12 0 12 0" />
381+
<!-- button Bg #89000000 -->
382+
<!--
383+
<Button></Button>
384+
-->
385+
</Grid>
386+
</ControlTemplate>
387+
</Setter.Value>
388+
</Setter>
389+
</Style>
369390

370391
<Style TargetType="{x:Type local:ColorZone}">
371392
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" />

0 commit comments

Comments
 (0)