Skip to content

Commit c518e19

Browse files
committed
added Style for ListView and ListViewItem
1 parent 837c923 commit c518e19

File tree

8 files changed

+284
-15
lines changed

8 files changed

+284
-15
lines changed

MainDemo.Wpf/Domain/MainWindowViewModel.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using System.Linq;
2-
using System.Windows.Controls;
3-
using MaterialDesignDemo;
1+
using MaterialDesignDemo;
42
using MaterialDesignDemo.Domain;
53
using MaterialDesignThemes.Wpf;
64
using MaterialDesignThemes.Wpf.Transitions;
5+
using System.Windows.Controls;
76

87
namespace MaterialDesignColors.WpfExample.Domain
98
{
@@ -13,14 +12,14 @@ public MainWindowViewModel()
1312
{
1413
DemoItems = new[]
1514
{
16-
new DemoItem("Home", new Home(),
15+
new DemoItem("Home", new Home(),
1716
new []
1817
{
1918
new DocumentationLink(DocumentationLinkType.Wiki, "https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/wiki", "WIKI"),
2019
DocumentationLink.DemoPageLink<Home>()
2120
}
2221
),
23-
new DemoItem("Palette", new PaletteSelector { DataContext = new PaletteSelectorViewModel() },
22+
new DemoItem("Palette", new PaletteSelector { DataContext = new PaletteSelectorViewModel() },
2423
new []
2524
{
2625
DocumentationLink.WikiLink("Brush-Names", "Brushes"),
@@ -30,7 +29,7 @@ public MainWindowViewModel()
3029
DocumentationLink.DemoPageLink<PaletteSelectorViewModel>("Demo View Model"),
3130
DocumentationLink.ApiLink<PaletteHelper>()
3231
}),
33-
new DemoItem("Buttons & Toggles", new Buttons(),
32+
new DemoItem("Buttons & Toggles", new Buttons(),
3433
new []
3534
{
3635
DocumentationLink.WikiLink("Button-Styles", "Buttons"),
@@ -46,10 +45,10 @@ public MainWindowViewModel()
4645
},
4746
new DemoItem("Fields", new TextFields(),
4847
new []
49-
{
48+
{
5049
DocumentationLink.DemoPageLink<TextFields>(),
5150
DocumentationLink.StyleLink("TextBox"),
52-
DocumentationLink.StyleLink("ComboBox"),
51+
DocumentationLink.StyleLink("ComboBox"),
5352
})
5453
{
5554
VerticalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
@@ -65,7 +64,7 @@ public MainWindowViewModel()
6564
new DemoItem("Sliders", new Sliders(), new []
6665
{
6766
DocumentationLink.DemoPageLink<Sliders>(),
68-
DocumentationLink.StyleLink("Sliders")
67+
DocumentationLink.StyleLink("Sliders")
6968
}),
7069
new DemoItem("Chips", new Chips(), new []
7170
{
@@ -93,7 +92,7 @@ public MainWindowViewModel()
9392
},
9493
new DemoItem("Icon Pack", new IconPack { DataContext = new IconPackViewModel() },
9594
new []
96-
{
95+
{
9796
DocumentationLink.DemoPageLink<IconPack>("Demo View"),
9897
DocumentationLink.DemoPageLink<IconPackViewModel>("Demo View Model"),
9998
DocumentationLink.ApiLink<PackIcon>()
@@ -109,18 +108,24 @@ public MainWindowViewModel()
109108
{
110109
DocumentationLink.DemoPageLink<Lists>("Demo View"),
111110
DocumentationLink.DemoPageLink<ListsAndGridsViewModel>("Demo View Model"),
112-
DocumentationLink.StyleLink("ListBox")
111+
DocumentationLink.StyleLink("ListBox")
112+
}),
113+
new DemoItem("ListViews", new ListViews { DataContext = new ListsAndGridsViewModel() },
114+
new DocumentationLink[]
115+
{
116+
113117
}),
118+
114119
new DemoItem("Trees", new Trees { DataContext = new TreesViewModel() },
115120
new []
116-
{
121+
{
117122
DocumentationLink.DemoPageLink<Trees>("Demo View"),
118123
DocumentationLink.DemoPageLink<TreesViewModel>("Demo View Model"),
119124
DocumentationLink.StyleLink("TreeView")
120125
}),
121126
new DemoItem("Grids", new Grids { DataContext = new ListsAndGridsViewModel()},
122127
new []
123-
{
128+
{
124129
DocumentationLink.DemoPageLink<Lists>("Demo View"),
125130
DocumentationLink.DemoPageLink<ListsAndGridsViewModel>("Demo View Model"),
126131
DocumentationLink.StyleLink("DataGrid")
@@ -185,7 +190,7 @@ public MainWindowViewModel()
185190
new DemoItem("Shadows", new Shadows(),
186191
new []
187192
{
188-
DocumentationLink.DemoPageLink<Shadows>(),
193+
DocumentationLink.DemoPageLink<Shadows>(),
189194
}),
190195
};
191196
}

MainDemo.Wpf/ListViews.xaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<UserControl x:Class="MaterialDesignDemo.ListViews"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:MaterialDesignDemo">
5+
<Grid Margin="8">
6+
<ListView Grid.Row="0" ItemsSource="{Binding Items1}">
7+
<ListView.View>
8+
<GridView>
9+
<GridViewColumn DisplayMemberBinding="{Binding Code}" Header="Code" />
10+
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Name" />
11+
<GridViewColumn DisplayMemberBinding="{Binding Description}" Header="Description" />
12+
</GridView>
13+
</ListView.View>
14+
</ListView>
15+
</Grid>
16+
</UserControl>

MainDemo.Wpf/ListViews.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MaterialDesignDemo
2+
{
3+
public partial class ListViews
4+
{
5+
public ListViews()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

MainDemo.Wpf/MaterialDesignDemo.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
<Compile Include="Lists.xaml.cs">
140140
<DependentUpon>Lists.xaml</DependentUpon>
141141
</Compile>
142+
<Compile Include="ListViews.xaml.cs">
143+
<DependentUpon>ListViews.xaml</DependentUpon>
144+
</Compile>
142145
<Compile Include="MenusAndToolBars.xaml.cs">
143146
<DependentUpon>MenusAndToolBars.xaml</DependentUpon>
144147
</Compile>
@@ -274,6 +277,10 @@
274277
<SubType>Designer</SubType>
275278
<Generator>MSBuild:Compile</Generator>
276279
</Page>
280+
<Page Include="ListViews.xaml">
281+
<SubType>Designer</SubType>
282+
<Generator>MSBuild:Compile</Generator>
283+
</Page>
277284
<Page Include="MainWindow.xaml">
278285
<Generator>MSBuild:Compile</Generator>
279286
<SubType>Designer</SubType>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Windows;
2+
3+
namespace MaterialDesignThemes.Wpf
4+
{
5+
public static class ListViewAssist
6+
{
7+
public static readonly DependencyProperty ListViewItemPaddingProperty = DependencyProperty.RegisterAttached(
8+
"ListViewItemPadding",
9+
typeof(Thickness),
10+
typeof(ListViewAssist),
11+
new FrameworkPropertyMetadata(new Thickness(13, 8, 8, 8), FrameworkPropertyMetadataOptions.Inherits));
12+
13+
public static void SetListViewItemPadding(DependencyObject element, Thickness value)
14+
{
15+
element.SetValue(ListViewItemPaddingProperty, value);
16+
}
17+
18+
public static Thickness GetListViewItemPadding(DependencyObject element)
19+
{
20+
return (Thickness)element.GetValue(ListViewItemPaddingProperty);
21+
}
22+
}
23+
}

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@
130130
<SubType>Designer</SubType>
131131
<Generator>MSBuild:Compile</Generator>
132132
</Page>
133+
<Page Include="Themes\MaterialDesignTheme.ListView.xaml">
134+
<SubType>Designer</SubType>
135+
<Generator>MSBuild:Compile</Generator>
136+
</Page>
133137
<Page Include="Themes\MaterialDesignTheme.Menu.xaml">
134138
<SubType>Designer</SubType>
135139
<Generator>MSBuild:Compile</Generator>
@@ -305,6 +309,7 @@
305309
<Compile Include="IconType.cs" />
306310
<Compile Include="ISnackbarMessageQueue.cs" />
307311
<Compile Include="ListBoxAssist.cs" />
312+
<Compile Include="ListViewAssist.cs" />
308313
<Compile Include="MessageQueueExtension.cs" />
309314
<Compile Include="PackIconExtension.cs" />
310315
<Compile Include="Palette.cs" />

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Defaults.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToolBarTray.xaml" />
3434
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToolTip.xaml" />
3535
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TreeView.xaml" />
36+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ListView.xaml" />
3637
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ValidationErrorTemplate.xaml" />
3738
</ResourceDictionary.MergedDictionaries>
3839
<SolidColorBrush x:Key="MaterialDesignLightBackground" Color="#FFFAFAFA"/>
@@ -42,7 +43,7 @@
4243
<SolidColorBrush x:Key="MaterialDesignDarkSeparatorBackground" Color="#1F000000" />
4344
<SolidColorBrush x:Key="MaterialDesignLightSeparatorBackground" Color="#1FFFFFFF" />
4445
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignRaisedButton}" />
45-
<Style TargetType="{x:Type Calendar}" BasedOn="{StaticResource MaterialDesignCalendarPortrait}" />
46+
<Style TargetType="{x:Type Calendar}" BasedOn="{StaticResource MaterialDesignCalendarPortrait}" />
4647
<Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}" />
4748
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MaterialDesignComboBox}" />
4849
<Style TargetType="{x:Type ContextMenu}" BasedOn="{StaticResource MaterialDesignContextMenu}" />
@@ -72,6 +73,8 @@
7273
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource MaterialDesignToolTip}" />
7374
<Style TargetType="{x:Type TreeView}" BasedOn="{StaticResource MaterialDesignTreeView}" />
7475
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource MaterialDesignTreeViewItem}" />
76+
<Style TargetType="{x:Type ListView}" BasedOn="{StaticResource MaterialDesignListView}" />
77+
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource MaterialDesignListViewItem}" />
7578
<Style TargetType="{x:Type Menu}" BasedOn="{StaticResource MaterialDesignMenu}" />
7679
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}" />
7780
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}" BasedOn="{StaticResource MaterialDesignSeparator}" />

0 commit comments

Comments
 (0)