Skip to content

Commit 14d4688

Browse files
committed
sample
1 parent 09c139d commit 14d4688

File tree

8 files changed

+184
-1
lines changed

8 files changed

+184
-1
lines changed

SimpleDataGrid.Example/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="SimpleDataGrid.Example.App"
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:SimpleDataGrid.Example"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

SimpleDataGrid.Example/App.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace SimpleDataGrid.Example;
6+
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly:ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
using SimpleDataGrid.Pagination;
3+
using System.Collections.Generic;
4+
5+
namespace SimpleDataGrid.Example;
6+
7+
public class MainViewModel
8+
{
9+
public PagedCollection<Person> People { get; }
10+
11+
public MainViewModel()
12+
{
13+
People = new PagedCollection<Person>(10);
14+
People.SetSource(GetPeople());
15+
}
16+
17+
private List<Person> GetPeople()
18+
{
19+
var people = new List<Person>();
20+
for (int i = 1; i <= 100; i++)
21+
{
22+
people.Add(new Person { Id = i, Name = $"Person {i}", Age = 20 + (i % 50) });
23+
}
24+
return people;
25+
}
26+
}
27+
28+
public class Person
29+
{
30+
public int Id { get; set; }
31+
public string Name { get; set; } = string.Empty;
32+
public int Age { get; set; }
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Window x:Class="SimpleDataGrid.Example.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:SimpleDataGrid.Example"
7+
mc:Ignorable="d"
8+
Title="MainWindow" Height="450" Width="800">
9+
<Window.DataContext>
10+
<local:MainViewModel />
11+
</Window.DataContext>
12+
<Grid>
13+
<Grid.RowDefinitions>
14+
<RowDefinition Height="Auto" />
15+
<RowDefinition Height="*" />
16+
<RowDefinition Height="Auto" />
17+
</Grid.RowDefinitions>
18+
19+
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5">
20+
<TextBox x:Name="SearchTextBox" Width="200" Margin="5" />
21+
<Button Content="Search" Click="SearchButton_Click" Margin="5" />
22+
</StackPanel>
23+
24+
<local:PersonPagedDataGrid x:Name="PagedDataGrid" Grid.Row="1" PagedSource="{Binding People}" AutoGenerateColumns="True" />
25+
26+
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
27+
<Button Content="Previous" Click="PreviousButton_Click" Margin="5" />
28+
<TextBlock Text="{Binding People.CurrentPage}" VerticalAlignment="Center" Margin="5" />
29+
<TextBlock Text="/" VerticalAlignment="Center" />
30+
<TextBlock Text="{Binding People.TotalPages}" VerticalAlignment="Center" Margin="5" />
31+
<Button Content="Next" Click="NextButton_Click" Margin="5" />
32+
</StackPanel>
33+
</Grid>
34+
</Window>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
using SimpleDataGrid.Controls;
3+
using System.Windows;
4+
5+
namespace SimpleDataGrid.Example
6+
{
7+
public partial class MainWindow : Window
8+
{
9+
public MainWindow()
10+
{
11+
InitializeComponent();
12+
}
13+
14+
private void PreviousButton_Click(object sender, RoutedEventArgs e)
15+
{
16+
var viewModel = (MainViewModel)DataContext;
17+
viewModel.People.PreviousPage();
18+
}
19+
20+
private void NextButton_Click(object sender, RoutedEventArgs e)
21+
{
22+
var viewModel = (MainViewModel)DataContext;
23+
viewModel.People.NextPage();
24+
}
25+
26+
private void SearchButton_Click(object sender, RoutedEventArgs e)
27+
{
28+
var viewModel = (MainViewModel)DataContext;
29+
viewModel.People.SetSearch(p => p.Name, SearchTextBox.Text);
30+
}
31+
}
32+
33+
public class PersonPagedDataGrid : PagedDataGrid<Person> { }
34+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
4+
<PropertyGroup>
5+
<OutputType>WinExe</OutputType>
6+
<TargetFramework>net9.0-windows</TargetFramework>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<UseWPF>true</UseWPF>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\SimpleDataGrid\SimpleDataGrid.csproj" />
14+
</ItemGroup>
15+
16+
</Project>

SimpleDataGrid.sln

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,60 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.14.36301.6 d17.14
4+
VisualStudioVersion = 17.14.36301.6
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDataGrid", "SimpleDataGrid\SimpleDataGrid.csproj", "{71B53291-75B2-4B5E-91B1-245E611AB4EA}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDataGrid.Tests", "SimpleDataGrid.Tests\SimpleDataGrid.Tests.csproj", "{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDataGrid.Example", "SimpleDataGrid.Example\SimpleDataGrid.Example.csproj", "{58D7B0EE-9725-416A-B688-608459668F8E}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
15+
Debug|x64 = Debug|x64
16+
Debug|x86 = Debug|x86
1317
Release|Any CPU = Release|Any CPU
18+
Release|x64 = Release|x64
19+
Release|x86 = Release|x86
1420
EndGlobalSection
1521
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1622
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1723
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Debug|x64.ActiveCfg = Debug|Any CPU
25+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Debug|x64.Build.0 = Debug|Any CPU
26+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Debug|x86.ActiveCfg = Debug|Any CPU
27+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Debug|x86.Build.0 = Debug|Any CPU
1828
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
1929
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Release|x64.ActiveCfg = Release|Any CPU
31+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Release|x64.Build.0 = Release|Any CPU
32+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Release|x86.ActiveCfg = Release|Any CPU
33+
{71B53291-75B2-4B5E-91B1-245E611AB4EA}.Release|x86.Build.0 = Release|Any CPU
2034
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2135
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Debug|x64.ActiveCfg = Debug|Any CPU
37+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Debug|x64.Build.0 = Debug|Any CPU
38+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Debug|x86.ActiveCfg = Debug|Any CPU
39+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Debug|x86.Build.0 = Debug|Any CPU
2240
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
2341
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Release|Any CPU.Build.0 = Release|Any CPU
42+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Release|x64.ActiveCfg = Release|Any CPU
43+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Release|x64.Build.0 = Release|Any CPU
44+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Release|x86.ActiveCfg = Release|Any CPU
45+
{6CB54D0C-857F-46FB-8A0D-5719DC0718BA}.Release|x86.Build.0 = Release|Any CPU
46+
{58D7B0EE-9725-416A-B688-608459668F8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{58D7B0EE-9725-416A-B688-608459668F8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{58D7B0EE-9725-416A-B688-608459668F8E}.Debug|x64.ActiveCfg = Debug|Any CPU
49+
{58D7B0EE-9725-416A-B688-608459668F8E}.Debug|x64.Build.0 = Debug|Any CPU
50+
{58D7B0EE-9725-416A-B688-608459668F8E}.Debug|x86.ActiveCfg = Debug|Any CPU
51+
{58D7B0EE-9725-416A-B688-608459668F8E}.Debug|x86.Build.0 = Debug|Any CPU
52+
{58D7B0EE-9725-416A-B688-608459668F8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{58D7B0EE-9725-416A-B688-608459668F8E}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{58D7B0EE-9725-416A-B688-608459668F8E}.Release|x64.ActiveCfg = Release|Any CPU
55+
{58D7B0EE-9725-416A-B688-608459668F8E}.Release|x64.Build.0 = Release|Any CPU
56+
{58D7B0EE-9725-416A-B688-608459668F8E}.Release|x86.ActiveCfg = Release|Any CPU
57+
{58D7B0EE-9725-416A-B688-608459668F8E}.Release|x86.Build.0 = Release|Any CPU
2458
EndGlobalSection
2559
GlobalSection(SolutionProperties) = preSolution
2660
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)