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:
@ -1,4 +1,5 @@
|
||||
using System.Windows;
|
||||
using Dialogs;
|
||||
using ModernWpf;
|
||||
using ModernWpfPlayground.Types;
|
||||
using Prism.Ioc;
|
||||
@ -22,6 +23,7 @@ namespace ModernWpfPlayground
|
||||
{
|
||||
containerRegistry.Register<MainWindow>();
|
||||
containerRegistry.Register<MainWindowViewModel>();
|
||||
containerRegistry.RegisterDialog<MessageBoxView, MessageBoxViewModel>();
|
||||
}
|
||||
|
||||
protected override Window CreateShell()
|
||||
|
@ -242,6 +242,7 @@
|
||||
HorizontalAlignment="Stretch"
|
||||
Command="{Binding SaveViewModelCommand}"
|
||||
Content="Save" />
|
||||
<Button Command="{Binding ShowDialogServiceCommand}" Content="Show dialog" />
|
||||
</ui:SimpleStackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
@ -275,7 +276,8 @@
|
||||
x:Name="TextBoxSwitch"
|
||||
Grid.Column="0"
|
||||
Width="145"
|
||||
Margin="0,0,5,0">
|
||||
Margin="0,0,5,0"
|
||||
VerticalAlignment="Top">
|
||||
<ToggleButton.Style>
|
||||
<Style BasedOn="{StaticResource {x:Type ToggleButton}}" TargetType="ToggleButton">
|
||||
<Setter Property="Content" Value="Read/Write" />
|
||||
@ -289,8 +291,12 @@
|
||||
</ToggleButton>
|
||||
<TextBox
|
||||
Grid.Column="1"
|
||||
AcceptsReturn="True"
|
||||
AcceptsTab="True"
|
||||
IsReadOnly="{Binding IsChecked, ElementName=TextBoxSwitch}"
|
||||
Text="Eine einfache Textbox" />
|
||||
MinLines="4"
|
||||
Text="{Binding MultiLineText}"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
<controls:PropertyPresenter Label="Hello" Value="{Binding BooleanValue}" />
|
||||
<controls:PropertyPresenter Label="Hello">
|
||||
|
@ -3,10 +3,12 @@ using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Dialogs;
|
||||
using Microsoft.Win32;
|
||||
using ModernWpfPlayground.MvvmStuff;
|
||||
using ModernWpfPlayground.Types;
|
||||
using Prism.Commands;
|
||||
using Prism.Services.Dialogs;
|
||||
using YamlDotNet.Serialization;
|
||||
using static ModernWpf.ThemeManager;
|
||||
|
||||
@ -15,14 +17,16 @@ namespace ModernWpfPlayground
|
||||
// ReSharper disable once ClassNeverInstantiated.Global
|
||||
public class MainWindowViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IDialogService _service;
|
||||
private const string AppName = "TaBEA 3.0.0";
|
||||
private string? _path;
|
||||
private string _title = AppName;
|
||||
private readonly ISerializer _serializer;
|
||||
private readonly IDeserializer _deserializer;
|
||||
|
||||
public MainWindowViewModel()
|
||||
public MainWindowViewModel(IDialogService service)
|
||||
{
|
||||
_service = service;
|
||||
ShowDialogCommand = new DelegateCommand(ShowDialog);
|
||||
CloseCommand = new DelegateCommand(() => Application.Current.Shutdown());
|
||||
OpenViewModelCommand = new DelegateCommand(LoadViewModel);
|
||||
@ -121,6 +125,25 @@ namespace ModernWpfPlayground
|
||||
set => SetProperty(value);
|
||||
}
|
||||
|
||||
public string MultiLineText
|
||||
{
|
||||
get => GetProperty("Multi line");
|
||||
set => SetProperty(value);
|
||||
}
|
||||
|
||||
public ICommand ShowDialogServiceCommand => new DelegateCommand(ShowDialogService);
|
||||
|
||||
private void ShowDialogService()
|
||||
{
|
||||
void executeCallBack(IDialogResult result)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
_service.Show(nameof(MessageBoxView), default, executeCallBack);
|
||||
|
||||
}
|
||||
|
||||
private static void SetTheme(ThemeMode themeMode) => Current.ApplicationTheme = themeMode.ToApplicationTheme();
|
||||
|
||||
private void ShowDialog()
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FastMember" Version="1.5.0" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.0" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.1" />
|
||||
<PackageReference Include="Prism.DryIoc" Version="8.0.0.1740-pre" />
|
||||
<PackageReference Include="Prism.Wpf" Version="8.0.0.1740-pre" />
|
||||
<PackageReference Include="YamlDotNet" Version="8.1.2" />
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Controls\Controls.csproj" />
|
||||
<ProjectReference Include="..\Dialogs\Dialogs.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -18,9 +18,9 @@ namespace ModernWpfPlayground.Types
|
||||
{
|
||||
return accentColor switch
|
||||
{
|
||||
AccentColors.Green => Color.FromRgb(0, 86, 76),
|
||||
AccentColors.Green => Color.FromRgb(33, 115, 70),
|
||||
AccentColors.Yellow => Color.FromRgb(164, 144, 0),
|
||||
AccentColors.Blue => Color.FromRgb(0, 120, 215),
|
||||
AccentColors.Blue => Color.FromRgb(43, 87, 154),
|
||||
AccentColors.Purple => Color.FromRgb(104, 33, 122),
|
||||
AccentColors.Red => Color.FromRgb(183, 71, 42),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(accentColor), accentColor, null)
|
||||
|
Reference in New Issue
Block a user