Skip to content

Commit c2a6325

Browse files
committed
data grid styles
1 parent d520163 commit c2a6325

15 files changed

+639
-150
lines changed

MaterialDesignColors.WpfExample/App.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Application x:Class="MaterialDesignColors.WpfExample.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
StartupUri="ProvingGround.xaml">
4+
StartupUri="MainWindow.xaml">
55
<Application.Resources>
66
<ResourceDictionary>
77
<ResourceDictionary.MergedDictionaries>

MaterialDesignColors.WpfExample/Domain/ListFieldsViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
using System.Collections.ObjectModel;
22
using System.ComponentModel;
33
using System.Runtime.CompilerServices;
4+
using System.Windows.Controls;
45

56
namespace MaterialDesignColors.WpfExample.Domain
67
{
78
public class ListsWindowViewModel : INotifyPropertyChanged
89
{
910
private readonly ObservableCollection<SelectableViewModel> _items1;
1011
private readonly ObservableCollection<SelectableViewModel> _items2;
12+
private readonly ObservableCollection<SelectableViewModel> _items3;
1113

1214
public ListsWindowViewModel()
1315
{
1416
_items1 = CreateData();
1517
_items2 = CreateData();
18+
_items3 = CreateData();
1619
}
1720

1821
private static ObservableCollection<SelectableViewModel> CreateData()
@@ -50,6 +53,11 @@ public ObservableCollection<SelectableViewModel> Items2
5053
get { return _items2; }
5154
}
5255

56+
public ObservableCollection<SelectableViewModel> Items3
57+
{
58+
get { return _items3; }
59+
}
60+
5361
public event PropertyChangedEventHandler PropertyChanged;
5462

5563
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)

MaterialDesignColors.WpfExample/Domain/SelectableViewModel.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Linq;
1+
using System.ComponentModel;
52
using System.Runtime.CompilerServices;
6-
using System.Text;
7-
using System.Threading.Tasks;
3+
84

95
namespace MaterialDesignColors.WpfExample.Domain
106
{
@@ -14,6 +10,7 @@ public class SelectableViewModel : INotifyPropertyChanged
1410
private string _name;
1511
private string _description;
1612
private char _code;
13+
private double _numeric;
1714

1815
public bool IsSelected
1916
{
@@ -59,6 +56,16 @@ public string Description
5956
}
6057
}
6158

59+
public double Numeric
60+
{
61+
get { return _numeric; }
62+
set
63+
{
64+
if (_numeric == value) return;
65+
_numeric = value;
66+
OnPropertyChanged();
67+
}
68+
}
6269

6370
public event PropertyChangedEventHandler PropertyChanged;
6471

MaterialDesignColors.WpfExample/ListsWindow.xaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:domain="clr-namespace:MaterialDesignColors.WpfExample.Domain"
5-
Title="Lists" Height="300" Width="800">
5+
Title="Lists" Height="500" Width="800">
66
<Window.Resources>
77
<ResourceDictionary>
88
<ResourceDictionary.MergedDictionaries>
@@ -16,6 +16,10 @@
1616
<ColumnDefinition Width="1*" />
1717
<ColumnDefinition Width="1*" />
1818
</Grid.ColumnDefinitions>
19+
<Grid.RowDefinitions>
20+
<RowDefinition Height="Auto" />
21+
<RowDefinition Height="*" />
22+
</Grid.RowDefinitions>
1923
<ListBox Grid.Column="0">
2024
<TextBlock>Plain</TextBlock>
2125
<TextBlock>Old</TextBlock>
@@ -77,5 +81,8 @@
7781
</DataTemplate>
7882
</ItemsControl.ItemTemplate>
7983
</ItemsControl>
84+
85+
<DataGrid ItemsSource="{Binding Items3}" CanUserSortColumns="True" CanUserAddRows="False"
86+
Grid.Row="1" Grid.ColumnSpan="3"/>
8087
</Grid>
8188
</Window>

MaterialDesignColors.WpfExample/ProvingGround.xaml

Lines changed: 8 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -50,142 +50,16 @@
5050
</ResourceDictionary>
5151
</ResourceDictionary.MergedDictionaries>
5252

53-
54-
55-
56-
5753
</ResourceDictionary>
5854

5955
</UserControl.Resources>
6056

61-
<DockPanel>
62-
<Menu IsMainMenu="True" DockPanel.Dock="Top">
63-
<MenuItem Header="_File">
64-
<MenuItem Header="Save">
65-
<MenuItem.Icon>
66-
<Viewbox Width="16" Height="16">
67-
<Canvas Width="24" Height="24">
68-
<Path Data="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z" Fill="Black" />
69-
</Canvas>
70-
</Viewbox>
71-
</MenuItem.Icon>
72-
</MenuItem>
73-
<MenuItem Header="Save As.." />
74-
<MenuItem Header="Exit">
75-
<MenuItem.Icon>
76-
<Viewbox Width="16" Height="16">
77-
<Canvas Width="24" Height="24">
78-
<Path Data="M19,3H5C3.89,3 3,3.89 3,5V9H5V5H19V19H5V15H3V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M10.08,15.58L11.5,17L16.5,12L11.5,7L10.08,8.41L12.67,11H3V13H12.67L10.08,15.58Z" Fill="Black" />
79-
</Canvas>
80-
</Viewbox>
81-
</MenuItem.Icon>
82-
</MenuItem>
83-
<Separator />
84-
<MenuItem Header="Excellent" IsCheckable="True" IsChecked="True" />
85-
<MenuItem Header="Rubbish" IsCheckable="True" />
86-
<MenuItem Header="Dig Deeper">
87-
<MenuItem Header="Enlightenment?" />
88-
<MenuItem Header="Disappointment" />
89-
</MenuItem>
90-
</MenuItem>
91-
<MenuItem Header="_Edit">
92-
<MenuItem Header="_Cut" Command="Cut">
93-
<MenuItem.Icon>
94-
<Viewbox Width="16" Height="16">
95-
<Canvas Width="24" Height="24">
96-
<Path Data="M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z" Fill="Black" />
97-
</Canvas>
98-
</Viewbox>
99-
</MenuItem.Icon>
100-
</MenuItem>
101-
<MenuItem Header="_Copy" Command="Copy">
102-
<MenuItem.Icon>
103-
<Viewbox Width="16" Height="16">
104-
<Canvas Width="24" Height="24">
105-
<Path Data="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" Fill="Black" />
106-
</Canvas>
107-
</Viewbox>
108-
</MenuItem.Icon>
109-
</MenuItem>
110-
<MenuItem Header="_Paste" Command="Paste">
111-
<MenuItem.Icon>
112-
<Viewbox Width="16" Height="16">
113-
<Canvas Width="24" Height="24">
114-
<Path Data="M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z" Fill="Black" />
115-
</Canvas>
116-
</Viewbox>
117-
</MenuItem.Icon>
118-
</MenuItem>
119-
</MenuItem>
120-
</Menu>
121-
<ToolBarTray DockPanel.Dock="Top">
122-
<ToolBar Style="{DynamicResource MaterialDesignToolBar}">
123-
<Button ToolTip="Follow me on Twitter" Click="Button_Click">
124-
<Viewbox Width="16" Height="16">
125-
<Canvas Width="24" Height="24">
126-
<Path Data="M17.71,9.33C17.64,13.95 14.69,17.11 10.28,17.31C8.46,17.39 7.15,16.81 6,16.08C7.34,16.29 9,15.76 9.9,15C8.58,14.86 7.81,14.19 7.44,13.12C7.82,13.18 8.22,13.16 8.58,13.09C7.39,12.69 6.54,11.95 6.5,10.41C6.83,10.57 7.18,10.71 7.64,10.74C6.75,10.23 6.1,8.38 6.85,7.16C8.17,8.61 9.76,9.79 12.37,9.95C11.71,7.15 15.42,5.63 16.97,7.5C17.63,7.38 18.16,7.14 18.68,6.86C18.47,7.5 18.06,7.97 17.56,8.33C18.1,8.26 18.59,8.13 19,7.92C18.75,8.45 18.19,8.93 17.71,9.33M20,2H4A2,2 0 0,0 2,4V20A2,2 0 0,0 4,22H20A2,2 0 0,0 22,20V4C22,2.89 21.1,2 20,2Z" Fill="Black" />
127-
</Canvas>
128-
</Viewbox>
129-
</Button>
130-
<Button ToolTip="Save">
131-
<Viewbox Width="16" Height="16">
132-
<Canvas Width="24" Height="24">
133-
<Path Data="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z" Fill="Black" />
134-
</Canvas>
135-
</Viewbox>
136-
</Button>
137-
<Separator />
138-
<Button Command="Cut" ToolTip="Cut" ToolBar.OverflowMode="AsNeeded">
139-
<Viewbox Width="16" Height="16">
140-
<Canvas Width="24" Height="24">
141-
<Path Data="M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z" Fill="Black" />
142-
</Canvas>
143-
</Viewbox>
144-
</Button>
145-
<Button Command="Copy" ToolTip="Copy that stuff" ToolBar.OverflowMode="AsNeeded">
146-
<Viewbox Width="16" Height="16">
147-
<Canvas Width="24" Height="24">
148-
<Path Data="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" Fill="Black" />
149-
</Canvas>
150-
</Viewbox>
151-
</Button>
152-
<Separator />
153-
<Button Command="Paste" ToolTip="Paste some stuff" ToolBar.OverflowMode="AsNeeded">
154-
<Viewbox Width="16" Height="16">
155-
<Canvas Width="24" Height="24">
156-
<Path Data="M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z" Fill="Black" />
157-
</Canvas>
158-
</Viewbox>
159-
</Button>
160-
<Separator />
161-
<Label Content="Font size:" VerticalAlignment="Center"/>
162-
<ComboBox>
163-
<ComboBoxItem Content="10"/>
164-
<ComboBoxItem IsSelected="True" Content="12"/>
165-
<ComboBoxItem Content="14"/>
166-
<ComboBoxItem Content="16"/>
167-
</ComboBox>
168-
<CheckBox>
169-
Check
170-
</CheckBox>
171-
<Button ToolTip="Take a nap" ToolBar.OverflowMode="Always">
172-
<Viewbox Width="16" Height="16">
173-
<Canvas Width="24" Height="24">
174-
<Path Data="M19,7H11V14H3V5H1V20H3V17H21V20H23V11A4,4 0 0,0 19,7M7,13A3,3 0 0,0 10,10A3,3 0 0,0 7,7A3,3 0 0,0 4,10A3,3 0 0,0 7,13Z" Fill="Black" />
175-
</Canvas>
176-
</Viewbox>
177-
</Button>
178-
<RadioButton GroupName="XXX">
179-
Radio
180-
</RadioButton>
181-
<RadioButton GroupName="XXX">
182-
Ga Ga
183-
</RadioButton>
184-
<ToggleButton>
185-
Switch
186-
</ToggleButton>
187-
</ToolBar>
188-
</ToolBarTray>
189-
</DockPanel>
190-
57+
<!--
58+
<wpf:ListSortDirectionIndicator Width="24" Height="24" Style="{DynamicResource MaterialDesignListSortDirectionIndicator}" ListSortDirection="Descending" />
59+
-->
60+
<DataGrid ItemsSource="{Binding Items}" CanUserAddRows="False" CanUserSortColumns="True">
61+
62+
</DataGrid>
63+
64+
19165
</UserControl>

MaterialDesignColors.WpfExample/ProvingGround.xaml.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
34
using System.ComponentModel;
45
using System.Linq;
56
using System.Runtime.CompilerServices;
@@ -14,6 +15,7 @@
1415
using System.Windows.Media.Imaging;
1516
using System.Windows.Navigation;
1617
using System.Windows.Shapes;
18+
using MaterialDesignColors.WpfExample.Domain;
1719

1820
namespace MaterialDesignColors.WpfExample
1921
{
@@ -38,8 +40,10 @@ private void Button_Click(object sender, RoutedEventArgs e)
3840
public class ProvingGroundViewModel : INotifyPropertyChanged
3941
{
4042
private string _name;
43+
private readonly ObservableCollection<SelectableViewModel> _items = CreateData();
4144

42-
public string Name
45+
46+
public string Name
4347
{
4448
get { return _name; }
4549
set
@@ -49,7 +53,37 @@ public string Name
4953
}
5054
}
5155

52-
public event PropertyChangedEventHandler PropertyChanged;
56+
public ObservableCollection<SelectableViewModel> Items
57+
{
58+
get { return _items; }
59+
}
60+
61+
private static ObservableCollection<SelectableViewModel> CreateData()
62+
{
63+
return new ObservableCollection<SelectableViewModel>
64+
{
65+
new SelectableViewModel
66+
{
67+
Code = 'M',
68+
Name = "Material Design",
69+
Description = "Material Design in XAML Toolkit"
70+
},
71+
new SelectableViewModel
72+
{
73+
Code = 'D',
74+
Name = "Dragablz",
75+
Description = "Dragablz Tab Control"
76+
},
77+
new SelectableViewModel
78+
{
79+
Code = 'P',
80+
Name = "Predator",
81+
Description = "If it bleeds, we can kill it"
82+
}
83+
};
84+
}
85+
86+
public event PropertyChangedEventHandler PropertyChanged;
5387

5488
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
5589
{

0 commit comments

Comments
 (0)