-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update DataGrid Examples in Demo app
- Loading branch information
Showing
9 changed files
with
160 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
demo/UraniumApp/Pages/DataGrids/EditorDataGridPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Bogus; | ||
using ReactiveUI.Fody.Helpers; | ||
using System.ComponentModel; | ||
|
||
namespace UraniumApp.Pages.DataGrids; | ||
public class EditorDataGridPageViewModel : BindableObject | ||
{ | ||
public List<ReactiveStudent> Items { get; } = new(); | ||
public EditorDataGridPageViewModel() | ||
{ | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
Items.Add(GenerateStudent()); | ||
} | ||
} | ||
|
||
private static Faker<ReactiveStudent> studentFaker = new Faker<ReactiveStudent>() | ||
.RuleFor(x => x.Id, f => f.IndexFaker) | ||
.RuleFor(x => x.Name, f => f.Person.FullName) | ||
.RuleFor(x => x.Age, f => f.Random.Number(14, 85)); | ||
|
||
public static ReactiveStudent GenerateStudent() | ||
{ | ||
return studentFaker.Generate(); | ||
} | ||
} | ||
|
||
public class ReactiveStudent : ReactiveUI.ReactiveObject | ||
{ | ||
[Reactive] public int Id { get; set; } | ||
[Reactive] public string Name { get; set; } | ||
[Reactive] public int Age { get; set; } | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 26 additions & 21 deletions
47
demo/UraniumApp/Pages/DataGrids/SimpleDataGridPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
using ReactiveUI.Fody.Helpers; | ||
using Bogus; | ||
using System.ComponentModel; | ||
|
||
namespace UraniumApp.Pages.DataGrids; | ||
public class SimpleDataGridPageViewModel : BindableObject | ||
{ | ||
static Random random = new(); | ||
public List<Student> Items { get; } = new(); | ||
public SimpleDataGridPageViewModel() | ||
{ | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
Items.Add(new Student | ||
{ | ||
Id = i, | ||
Name = "Person " + i, | ||
Age = random.Next(14, 85), | ||
}); | ||
} | ||
public List<Student> Items { get; } = new(); | ||
public SimpleDataGridPageViewModel() | ||
{ | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
Items.Add(GenerateStudent()); | ||
} | ||
} | ||
|
||
private static Faker<Student> studentFaker = new Faker<Student>() | ||
.RuleFor(x => x.Id, f => f.IndexFaker) | ||
.RuleFor(x => x.Name, f => f.Person.FullName) | ||
.RuleFor(x => x.Age, f => f.Random.Number(14, 85)); | ||
|
||
public static Student GenerateStudent() | ||
{ | ||
return studentFaker.Generate(); | ||
} | ||
|
||
public class Student | ||
{ | ||
[DisplayName("Identity")] | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public int Age { get; set; } | ||
} | ||
public class Student : ReactiveUI.ReactiveObject | ||
{ | ||
[DisplayName("Identity Number")] | ||
[Reactive] public int Id { get; set; } | ||
[Reactive] public string Name { get; set; } | ||
[Reactive] public int Age { get; set; } | ||
} | ||
} |
Oops, something went wrong.