Skip to content

Commit 55bc9db

Browse files
committed
Add blank ObservableValidator sample page
1 parent a136eeb commit 55bc9db

File tree

7 files changed

+75
-0
lines changed

7 files changed

+75
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.ComponentModel;
6+
using MvvmSample.Core.Services;
7+
8+
namespace MvvmSample.Core.ViewModels;
9+
10+
public partial class ObservableValidatorPageViewModel : SamplePageViewModel
11+
{
12+
public ObservableValidatorPageViewModel(IFilesService filesService)
13+
: base(filesService)
14+
{
15+
}
16+
17+
public ObservableForm Form { get; } = new();
18+
19+
public partial class ObservableForm : ObservableValidator
20+
{
21+
22+
}
23+
}

samples/MvvmSampleUwp/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
5555
.AddTransient<IocPageViewModel>()
5656
.AddTransient<MessengerPageViewModel>()
5757
.AddTransient<ObservableObjectPageViewModel>()
58+
.AddTransient<ObservableValidatorPageViewModel>()
5859
.AddTransient<RelayCommandPageViewModel>()
5960
.AddTransient<SamplePageViewModel>()
6061
.BuildServiceProvider());

samples/MvvmSampleUwp/MvvmSampleUwp.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
<Compile Include="Views\BuildingTheUIPage.xaml.cs">
140140
<DependentUpon>BuildingTheUIPage.xaml</DependentUpon>
141141
</Compile>
142+
<Compile Include="Views\ObservableValidatorPage.xaml.cs">
143+
<DependentUpon>ObservableValidatorPage.xaml</DependentUpon>
144+
</Compile>
142145
<Compile Include="Views\RedditServicePage.xaml.cs">
143146
<DependentUpon>RedditServicePage.xaml</DependentUpon>
144147
</Compile>
@@ -291,6 +294,10 @@
291294
<Generator>MSBuild:Compile</Generator>
292295
<SubType>Designer</SubType>
293296
</Page>
297+
<Page Include="Views\ObservableValidatorPage.xaml">
298+
<Generator>MSBuild:Compile</Generator>
299+
<SubType>Designer</SubType>
300+
</Page>
294301
<Page Include="Views\RedditServicePage.xaml">
295302
<Generator>MSBuild:Compile</Generator>
296303
<SubType>Designer</SubType>

samples/MvvmSampleUwp/Shell.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
Content="ObservableObject"
6262
Icon="Sort"
6363
ToolTipService.ToolTip="A base class for observable objects, with built-in support for INotifyPropertyChanged." />
64+
<muxc:NavigationViewItem
65+
x:Name="ObservableValidatorItem"
66+
Content="ObservableValidator"
67+
Icon="AllApps"
68+
ToolTipService.ToolTip="A base class for validator objects, with built-in support for INotifyDataErrorInfo." />
6469
<muxc:NavigationViewItem
6570
Content="Commands"
6671
Icon="Calendar"

samples/MvvmSampleUwp/Shell.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public Shell()
3030
{
3131
new SampleEntry(IntroductionItem, typeof(IntroductionPage)),
3232
new SampleEntry(ObservableObjectItem, typeof(ObservableObjectPage), "ObservableObject", "observable inotify property changed propertychanging changing"),
33+
new SampleEntry(ObservableValidatorItem, typeof(ObservableValidatorPage), "ObservableValidator", "observable form validation validate data error inotify property changed propertychanging changing"),
3334
new SampleEntry(CommandsItem, typeof(RelayCommandPage), "RelayCommand and RelayCommand<T>", "commands icommand relaycommand binding"),
3435
new SampleEntry(AsyncCommandsItem, typeof(AsyncRelayCommandPage), "AsyncRelayCommand and AsyncRelayCommand<T>", "asynccommands icommand relaycommand binding asynchronous"),
3536
new SampleEntry(MessengerItem, typeof(MessengerPage), "Messenger and IMessenger", "messenger messaging message receiver recipient"),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Page
2+
x:Class="MvvmSampleUwp.Views.ObservableValidatorPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
NavigationCacheMode="Enabled"
8+
mc:Ignorable="d">
9+
10+
<ScrollViewer Padding="{StaticResource DocumentationPageContentPadding}" CanContentRenderOutsideBounds="True">
11+
<StackPanel Spacing="16">
12+
</StackPanel>
13+
</ScrollViewer>
14+
</Page>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.DependencyInjection;
6+
using MvvmSample.Core.ViewModels;
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace MvvmSampleUwp.Views;
10+
11+
/// <summary>
12+
/// An empty page that can be used on its own or navigated to within a Frame.
13+
/// </summary>
14+
public sealed partial class ObservableValidatorPage : Page
15+
{
16+
public ObservableValidatorPage()
17+
{
18+
this.InitializeComponent();
19+
20+
DataContext = Ioc.Default.GetRequiredService<ObservableValidatorPageViewModel>();
21+
}
22+
23+
public ObservableValidatorPageViewModel ViewModel => (ObservableValidatorPageViewModel)DataContext;
24+
}

0 commit comments

Comments
 (0)