Skip to content

Commit 6e87fad

Browse files
committed
icon pack demo
1 parent 3843260 commit 6e87fad

File tree

10 files changed

+576
-20
lines changed

10 files changed

+576
-20
lines changed

MainDemo.Wpf/IconPack.xaml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,61 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:materialDesignDemo="clr-namespace:MaterialDesignDemo"
7+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
8+
xmlns:virtualCollection="clr-namespace:VirtualCollection.VirtualCollection"
79
mc:Ignorable="d"
810
d:DesignHeight="300" d:DesignWidth="300"
911
d:DesignData="{d:DesignInstance materialDesignDemo:IconPackViewModel, IsDesignTimeCreatable=False}">
1012
<UserControl.Resources>
1113
<ResourceDictionary>
1214
<ResourceDictionary.MergedDictionaries>
13-
<!--
14-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/"></ResourceDictionary>
15-
-->
15+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
1616
</ResourceDictionary.MergedDictionaries>
1717
</ResourceDictionary>
1818
</UserControl.Resources>
1919
<Grid>
20-
<TextBlock>Icons</TextBlock>
21-
20+
<Grid.RowDefinitions>
21+
<RowDefinition Height="Auto" />
22+
<RowDefinition Height="*" />
23+
<RowDefinition Height="Auto" />
24+
</Grid.RowDefinitions>
25+
<StackPanel>
26+
<TextBlock Style="{StaticResource MaterialDesignDisplay2TextBlock}">Icon Pack</TextBlock>
27+
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}"
28+
Margin="0 8 0 0">
29+
Material Design In XAML Toolkit includes the Material Design Icons collection.
30+
</TextBlock>
31+
<TextBlock Margin="0 8 0 0">
32+
For more information on Material Design Icons see the official website:
33+
<Hyperlink Command="{Binding OpenDotComCommand}">materialdesignicons.com</Hyperlink>
34+
</TextBlock>
35+
</StackPanel>
36+
<ListBox ItemsSource="{Binding Kinds}" Grid.Row="1" Margin="0 8 0 0"
37+
x:Name="KindsListBox">
38+
<ListBox.ItemsPanel>
39+
<ItemsPanelTemplate>
40+
<virtualCollection:VirtualizingWrapPanel ItemHeight="80" ItemWidth="80" />
41+
</ItemsPanelTemplate>
42+
</ListBox.ItemsPanel>
43+
<ListBox.ItemTemplate>
44+
<DataTemplate DataType="materialDesign:PackIconKind">
45+
<DockPanel ToolTip="{Binding }" Width="64" Height="64" Background="Transparent">
46+
<TextBlock Text="{Binding }" DockPanel.Dock="Bottom" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center" />
47+
<materialDesign:PackIcon Kind="{Binding }" VerticalAlignment="Center" HorizontalAlignment="Center"
48+
Width="32" Height="32"
49+
/>
50+
</DockPanel>
51+
</DataTemplate>
52+
</ListBox.ItemTemplate>
53+
</ListBox>
54+
<materialDesign:ColorZone Mode="PrimaryLight" Grid.Row="2" Margin="0 8 0 0" CornerRadius="2" materialDesign:ShadowAssist.ShadowDepth="Depth2">
55+
<StackPanel Orientation="Horizontal" Margin="8">
56+
<TextBlock Margin="8 0 0 0" Style="{StaticResource MaterialDesignSubheadingTextBlock}" VerticalAlignment="Center">Usage:</TextBlock>
57+
<TextBox IsReadOnly="True" Margin="8 0 8 0"
58+
GotFocus="TextBox_OnGotFocus"
59+
Text="{Binding ElementName=KindsListBox, Path=SelectedValue, StringFormat='&lt;materialDesign:PackIcon Kind=&quot;{0}&quot; \/>'}" />
60+
<materialDesign:PackIcon Kind="{Binding ElementName=KindsListBox, Path=SelectedValue}" VerticalAlignment="Center" />
61+
</StackPanel>
62+
</materialDesign:ColorZone>
2263
</Grid>
2364
</UserControl>

MainDemo.Wpf/IconPack.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,11 @@ public IconPack()
2424
{
2525
InitializeComponent();
2626
}
27+
28+
private void TextBox_OnGotFocus(object sender, RoutedEventArgs e)
29+
{
30+
var textBox = (TextBox)sender;
31+
textBox.Dispatcher.BeginInvoke(new Action(textBox.SelectAll));
32+
}
2733
}
2834
}

MainDemo.Wpf/IconPackViewModel.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Input;
8+
using MaterialDesignColors.WpfExample.Domain;
9+
using MaterialDesignThemes.Wpf;
10+
11+
namespace MaterialDesignDemo
12+
{
13+
public class IconPackViewModel
14+
{
15+
private readonly Lazy<IEnumerable<PackIconKind>> _packIconKinds;
16+
17+
public IconPackViewModel()
18+
{
19+
OpenDotComCommand = new AnotherCommandImplementation(OpenDotCom);
20+
_packIconKinds = new Lazy<IEnumerable<PackIconKind>>(() =>
21+
Enum.GetValues(typeof (PackIconKind)).OfType<PackIconKind>()
22+
.OrderBy(k => k.ToString(), StringComparer.InvariantCultureIgnoreCase).ToList()
23+
);
24+
25+
}
26+
27+
public ICommand OpenDotComCommand { get; }
28+
29+
public IEnumerable<PackIconKind> Kinds => _packIconKinds.Value;
30+
31+
private void OpenDotCom(object obj)
32+
{
33+
Process.Start("https://materialdesignicons.com/");
34+
}
35+
36+
37+
}
38+
}

MainDemo.Wpf/IconsViewModel.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

MainDemo.Wpf/MaterialDesignDemo.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
<Generator>MSBuild:Compile</Generator>
6868
<SubType>Designer</SubType>
6969
</ApplicationDefinition>
70+
<Compile Include="..\paket-files\samueldjack\VirtualCollection\VirtualCollection\VirtualCollection\VirtualizingWrapPanel.cs">
71+
<Link>VirtualCollection\VirtualizingWrapPanel.cs</Link>
72+
</Compile>
7073
<Compile Include="Buttons.xaml.cs">
7174
<DependentUpon>Buttons.xaml</DependentUpon>
7275
</Compile>
@@ -112,7 +115,7 @@
112115
<Compile Include="IconPack.xaml.cs">
113116
<DependentUpon>IconPack.xaml</DependentUpon>
114117
</Compile>
115-
<Compile Include="IconsViewModel.cs" />
118+
<Compile Include="IconPackViewModel.cs" />
116119
<Compile Include="Lists.xaml.cs">
117120
<DependentUpon>Lists.xaml</DependentUpon>
118121
</Compile>

paket-files/ControlzEx/ControlzEx/src/ControlzEx/paket.dependencies

Whitespace-only changes.

0 commit comments

Comments
 (0)