Skip to content

Commit 3f97089

Browse files
committed
Added WindowManager sample
1 parent 41a0c7c commit 3f97089

File tree

11 files changed

+133
-9
lines changed

11 files changed

+133
-9
lines changed

assets/SampleIcons.afdesign

-1.54 KB
Binary file not shown.

samples/MADE.Samples/MADE.Samples.Shared/Features/Home/ViewModels/MainPageViewModel.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ public MainPageViewModel(INavigationService navigationService, IMessenger messen
2929
new Sample(
3030
"FilePicker",
3131
typeof(FilePickerPage),
32-
string.Empty,
3332
"/Features/Samples/Assets/FilePicker/FilePicker.png"),
3433
new Sample(
3534
"InputValidator",
3635
typeof(InputValidatorPage),
37-
string.Empty,
3836
"/Features/Samples/Assets/InputValidator/InputValidator.png")
3937
}
4038
},
@@ -46,8 +44,11 @@ public MainPageViewModel(INavigationService navigationService, IMessenger messen
4644
new Sample(
4745
"AppDialog",
4846
typeof(AppDialogPage),
49-
string.Empty,
50-
"/Features/Samples/Assets/AppDialog/AppDialog.png")
47+
"/Features/Samples/Assets/AppDialog/AppDialog.png"),
48+
new Sample(
49+
"WindowManager",
50+
typeof(WindowManagerPage),
51+
"/Features/Samples/Assets/WindowManager/WindowManager.png")
5152
}
5253
}
5354
};
3.67 KB
Loading
2.81 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
private async Task ShowNewWindowAsync()
2+
{
3+
await WindowManager.CreateNewWindowForPageAsync(typeof(WindowManagerPage));
4+
}

samples/MADE.Samples/MADE.Samples.Shared/Features/Samples/Data/Sample.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ public Sample()
88
{
99
}
1010

11-
public Sample(string name, Type page, string description, string iconPath)
11+
public Sample(string name, Type page, string iconPath)
1212
{
1313
this.Name = name;
1414
this.Page = page;
15-
this.Description = description;
1615
this.IconPath = iconPath;
1716
}
1817

1918
public string Name { get; set; }
2019

21-
public string Description { get; set; }
22-
2320
public string IconPath { get; set; }
2421

2522
public Type Page { get; set; }

samples/MADE.Samples/MADE.Samples.Shared/Features/Samples/Pages/FilePickerPage.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
<samples:SampleControl.Sample>
5757
<made:FilePicker
5858
x:Name="FilePickerControl"
59-
Margin="0,12,0,0"
6059
AppendFiles="True"
6160
FileTypes="{x:Bind ViewModel.FilePickerTypes}"
6261
Files="{x:Bind ViewModel.FilePickerFiles}"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<pages:MvvmPage
2+
x:Class="MADE.Samples.Features.Samples.Pages.WindowManagerPage"
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:made="using:MADE.UI.Controls"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:pages="using:MADE.UI.Views.Navigation.Pages"
9+
xmlns:samples="using:MADE.Samples.Infrastructure.Controls"
10+
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
11+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
12+
mc:Ignorable="d">
13+
14+
<Grid>
15+
<Grid.RowDefinitions>
16+
<RowDefinition Height="Auto" />
17+
<RowDefinition Height="*" />
18+
</Grid.RowDefinitions>
19+
20+
<win:CommandBar>
21+
<win:CommandBar.Content>
22+
<Button
23+
x:Name="BackButton"
24+
VerticalAlignment="Top"
25+
Command="{x:Bind ViewModel.GoBackCommand}"
26+
IsEnabled="{x:Bind Frame.CanGoBack, Mode=OneWay}"
27+
Style="{StaticResource NavigationBackButtonNormalStyle}"
28+
ToolTipService.ToolTip="Back" />
29+
</win:CommandBar.Content>
30+
</win:CommandBar>
31+
32+
<Grid Grid.Row="1" Padding="16">
33+
<Grid.RowDefinitions>
34+
<RowDefinition Height="Auto" />
35+
<RowDefinition Height="Auto" />
36+
<RowDefinition Height="*" />
37+
</Grid.RowDefinitions>
38+
39+
<TextBlock
40+
Margin="0,0,0,16"
41+
Style="{StaticResource TitleTextBlockStyle}"
42+
Text="WindowManager helper" />
43+
44+
<TextBlock
45+
Grid.Row="1"
46+
Margin="0,0,0,48"
47+
Style="{StaticResource BaseTextBlockStyle}"
48+
Text="The WindowManager is UI helper that provides a mechanism to launch additional windows for an application through a similar implementation to navigating from page to page with the Frame. The WindowManager takes advantage of the ViewServiceManager approach by registering necessary view specific dependencies within a container that can be referenced anywhere in an application. This allows multiple application windows to be able to communicate with each other seamlessly." />
49+
50+
<ScrollViewer Grid.Row="2">
51+
<Grid>
52+
<samples:SampleControl CodeSource="WindowManager/WindowManagerCode.txt" SampleName="Launch additional application windows">
53+
<samples:SampleControl.Sample>
54+
<Button Command="{x:Bind ViewModel.ShowNewWindowCommand}" Content="Launch new window" />
55+
</samples:SampleControl.Sample>
56+
</samples:SampleControl>
57+
</Grid>
58+
</ScrollViewer>
59+
</Grid>
60+
</Grid>
61+
</pages:MvvmPage>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace MADE.Samples.Features.Samples.Pages
2+
{
3+
using CommunityToolkit.Mvvm.Messaging;
4+
using MADE.Samples.Features.Samples.ViewModels;
5+
using MADE.UI.Views.Navigation;
6+
using MADE.UI.Views.Navigation.Pages;
7+
using Microsoft.Extensions.DependencyInjection;
8+
9+
public sealed partial class WindowManagerPage : MvvmPage
10+
{
11+
public WindowManagerPage()
12+
{
13+
this.InitializeComponent();
14+
this.DataContext = new WindowManagerPageViewModel(
15+
App.Services.GetService<INavigationService>(),
16+
App.Services.GetService<IMessenger>());
17+
}
18+
19+
public WindowManagerPageViewModel ViewModel => this.DataContext as WindowManagerPageViewModel;
20+
}
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace MADE.Samples.Features.Samples.ViewModels
2+
{
3+
using System.Threading.Tasks;
4+
using System.Windows.Input;
5+
using CommunityToolkit.Mvvm.Input;
6+
using CommunityToolkit.Mvvm.Messaging;
7+
using MADE.Samples.Features.Samples.Pages;
8+
using MADE.UI.ViewManagement;
9+
using MADE.UI.Views.Navigation;
10+
using MADE.UI.Views.Navigation.ViewModels;
11+
12+
public class WindowManagerPageViewModel : PageViewModel
13+
{
14+
public WindowManagerPageViewModel(INavigationService navigationService, IMessenger messenger)
15+
: base(navigationService, messenger)
16+
{
17+
}
18+
19+
public ICommand ShowNewWindowCommand => new AsyncRelayCommand(this.ShowNewWindowAsync);
20+
21+
private async Task ShowNewWindowAsync()
22+
{
23+
await WindowManager.CreateNewWindowForPageAsync(typeof(WindowManagerPage));
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)