generated from unoplatform/template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Using data as viewmodel for navigation
- Loading branch information
1 parent
a506c6b
commit 7ade063
Showing
10 changed files
with
107 additions
and
15 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
5 changes: 5 additions & 0 deletions
5
...les/Playground/Playground/Playground/Playground.Shared/ViewModels/ItemDetailsViewModel.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,5 @@ | ||
namespace Playground.ViewModels; | ||
|
||
public record ItemDetailsViewModel(Widget Widget) | ||
{ | ||
} |
18 changes: 18 additions & 0 deletions
18
samples/Playground/Playground/Playground/Playground.Shared/ViewModels/ListViewModel.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,18 @@ | ||
namespace Playground.ViewModels; | ||
|
||
public class ListViewModel | ||
{ | ||
public ItemDetailsViewModel[] Items { get; } = new ItemDetailsViewModel[] | ||
{ | ||
new ItemDetailsViewModel(new Widget("Fred",49.0)), | ||
new ItemDetailsViewModel(new Widget("Jane",34.2)), | ||
new ItemDetailsViewModel(new Widget("Bob",46.3)), | ||
new ItemDetailsViewModel(new Widget("Frank",55.2)), | ||
new ItemDetailsViewModel(new Widget("Matt",45.7)), | ||
new ItemDetailsViewModel(new Widget("Shane",99.3)), | ||
new ItemDetailsViewModel(new Widget("Helen",23.7)), | ||
new ItemDetailsViewModel(new Widget("Jo",34.5)), | ||
new ItemDetailsViewModel(new Widget("Mike",23.3)) | ||
}; | ||
|
||
} |
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
10 changes: 10 additions & 0 deletions
10
samples/Playground/Playground/Playground/Playground.Shared/Views/ItemDetailsPage.xaml.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,10 @@ | ||
| ||
namespace Playground.Views; | ||
|
||
public sealed partial class ItemDetailsPage : Page | ||
{ | ||
public ItemDetailsPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
samples/Playground/Playground/Playground/Playground.Shared/Views/ListPage.xaml
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,24 @@ | ||
<Page | ||
x:Class="Playground.Views.ListPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Playground.Views" | ||
xmlns:vm="using:Playground.ViewModels" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
xmlns:utu="using:Uno.Toolkit.UI" | ||
xmlns:uen="using:Uno.Extensions.Navigation.UI" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<Grid> | ||
<ListView ItemsSource="{Binding Items}" | ||
uen:Navigation.Request="ItemDetails"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate x:Type="vm:ItemDetailsViewModel"> | ||
<TextBlock Text="{x:Bind Widget.Name}" FontSize="24"/> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
</Grid> | ||
</Page> |
4 changes: 2 additions & 2 deletions
4
...yground.Shared/Views/ListViewPage.xaml.cs → .../Playground.Shared/Views/ListPage.xaml.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
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