mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-06-30 17:50:51 +02:00
Try to create a prism dialog service with custom modern ui window
This commit is contained in:
10
Dialogs/AssemblyInfo.cs
Normal file
10
Dialogs/AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
32
Dialogs/DialogService.cs
Normal file
32
Dialogs/DialogService.cs
Normal file
@ -0,0 +1,32 @@
|
||||
//using System;
|
||||
//using Prism.Services.Dialogs;
|
||||
|
||||
//namespace Dialogs
|
||||
//{
|
||||
// public class DialogService : IDialogService
|
||||
// {
|
||||
// /// <inheritdoc />
|
||||
// public void Show(string name, IDialogParameters parameters, Action<IDialogResult> callback)
|
||||
// {
|
||||
// TODO_IMPLEMENT_ME();
|
||||
// }
|
||||
|
||||
// /// <inheritdoc />
|
||||
// public void Show(string name, IDialogParameters parameters, Action<IDialogResult> callback, string windowName)
|
||||
// {
|
||||
// TODO_IMPLEMENT_ME();
|
||||
// }
|
||||
|
||||
// /// <inheritdoc />
|
||||
// public void ShowDialog(string name, IDialogParameters parameters, Action<IDialogResult> callback)
|
||||
// {
|
||||
// TODO_IMPLEMENT_ME();
|
||||
// }
|
||||
|
||||
// /// <inheritdoc />
|
||||
// public void ShowDialog(string name, IDialogParameters parameters, Action<IDialogResult> callback, string windowName)
|
||||
// {
|
||||
// TODO_IMPLEMENT_ME();
|
||||
// }
|
||||
// }
|
||||
//}
|
18
Dialogs/Dialogs.csproj
Normal file
18
Dialogs/Dialogs.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Prism.Wpf" Version="8.0.0.1740-pre" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="ModernWpf.Controls">
|
||||
<HintPath>..\..\..\.nuget\packages\modernwpfui\0.9.1\lib\netcoreapp3.0\ModernWpf.Controls.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
27
Dialogs/MessageBoxView.xaml
Normal file
27
Dialogs/MessageBoxView.xaml
Normal file
@ -0,0 +1,27 @@
|
||||
<ui:ContentDialog
|
||||
x:Class="Dialogs.MessageBoxView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Dialogs"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mvvm="http://prismlibrary.com/"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
Title="Save your work?"
|
||||
d:DataContext="{d:DesignInstance local:MessageBoxViewModel}"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mvvm:ViewModelLocator.AutoWireViewModel="True"
|
||||
CloseButtonText="Cancel"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonCommand="{Binding CloseDialogCommand}"
|
||||
PrimaryButtonCommandParameter="true"
|
||||
PrimaryButtonText="Save"
|
||||
SecondaryButtonText="Don't Save"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<!-- Content body -->
|
||||
<TextBlock Text="Lorem ipsum dolor sit amet, adipisicing elit." TextWrapping="Wrap" />
|
||||
<CheckBox Content="Upload your content to the cloud." />
|
||||
</StackPanel>
|
||||
</ui:ContentDialog>
|
26
Dialogs/MessageBoxView.xaml.cs
Normal file
26
Dialogs/MessageBoxView.xaml.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für MessageBoxView.xaml
|
||||
/// </summary>
|
||||
public partial class MessageBoxView
|
||||
{
|
||||
public MessageBoxView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
50
Dialogs/MessageBoxViewModel.cs
Normal file
50
Dialogs/MessageBoxViewModel.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using Prism.Commands;
|
||||
using Prism.Services.Dialogs;
|
||||
|
||||
namespace Dialogs
|
||||
{
|
||||
public class MessageBoxViewModel : IDialogAware
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool CanCloseDialog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnDialogClosed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Title { get; }
|
||||
|
||||
|
||||
private DelegateCommand<string> _closeDialogCommand;
|
||||
public DelegateCommand<string> CloseDialogCommand => _closeDialogCommand ??= new DelegateCommand<string>(CloseDialog);
|
||||
|
||||
private void CloseDialog(string obj)
|
||||
{
|
||||
if (obj == "true")
|
||||
{
|
||||
RaiseRequestClose(new DialogResult(ButtonResult.OK));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action<IDialogResult> RequestClose;
|
||||
|
||||
public virtual void RaiseRequestClose(IDialogResult dialogResult)
|
||||
{
|
||||
RequestClose?.Invoke(dialogResult);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user