-
[Prism] DialogC#/Prism 2023. 1. 6. 16:57
모듈을 Dialog로 등록해서 사용.
ViewModel에 IDialogAware인터페이스 추가
ShowDialog
public void NewProject() { //using the dialog service as-is var newProjectData = new NewProject(); var dialogParameters = new DialogParameters(); dialogParameters.Add("newProject", newProjectData); //using the dialog service as-is _dialogService.ShowDialog("NewProjectView", dialogParameters, r => { if (r.Result == ButtonResult.OK) { //"Result is OK"; IProjectInfo info = new LSProject(newProjectData.Name, newProjectData.UserName, newProjectData.Path, newProjectData.Description); _projectInfo = info; eventManager.PublishCustomEvent(info); } else if (r.Result == ButtonResult.Cancel) { //"Result is Cancel"; } else { //"Close Button"; } }); }
View
ViewModel
public event Action<IDialogResult> RequestClose; protected virtual void CloseDialog(string parameter) { ButtonResult result = ButtonResult.None; if (parameter?.ToLower() == "true") { // name, path 체크 bool isValid = NewProjectData.ValidateName(NewProjectData.Name); if (false == isValid) { MessageBox.Show(NewProjectData.Error); return; } isValid = NewProjectData.ValidatePath(NewProjectData.Path); if (false == isValid) { MessageBox.Show(NewProjectData.Error); return; } result = ButtonResult.OK; } else if (parameter?.ToLower() == "false") result = ButtonResult.Cancel; RaiseRequestClose(new DialogResult(result)); } public virtual void RaiseRequestClose(IDialogResult dialogResult) { RequestClose?.Invoke(dialogResult); } public virtual bool CanCloseDialog() { return true; } public virtual void OnDialogClosed() { } public virtual void OnDialogOpened(IDialogParameters parameters) { NewProjectData = parameters.GetValue<NewProject>("newProject"); }
Customize Dialog window prism
<UserControl x:Class="HelloWorld.Dialogs.NotificationDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:prism="http://prismlibrary.com/" prism:ViewModelLocator.AutoWireViewModel="True" Width="300" Height="150"> <prism:Dialog.WindowStyle> <Style TargetType="Window"> <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterScreen" /> <Setter Property="ResizeMode" Value="NoResize"/> <Setter Property="ShowInTaskbar" Value="False"/> <Setter Property="SizeToContent" Value="WidthAndHeight"/> </Style> </prism:Dialog.WindowStyle> <Grid x:Name="LayoutRoot" Margin="5"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <TextBlock Text="{Binding Message}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" TextWrapping="Wrap" /> <Button Command="{Binding CloseDialogCommand}" CommandParameter="True" Content="OK" Width="75" Height="25" HorizontalAlignment="Right" Margin="0,10,0,0" Grid.Row="1" IsDefault="True" /> </Grid> </UserControl>
https://stackoverflow.com/questions/56840028/customize-dialog-window-prism
Customize Dialog window prism
I have implemented the new DialogService as shown in this issue A New IDialogService for WPF However, this doesn't explain how to edit the window of the dialog itself, since the NotificationDialog ...
stackoverflow.com
https://stackoverflow.com/questions/34125982/prism-pop-up-new-window-in-wpf
Prism pop-up new window in WPF
How can I open/close a new window in WPF without violating rules of the MVVM pattern? I just want to mimic the login module of ms office outlook. I've already read this article, but there are an e...
stackoverflow.com
728x90'C# > Prism' 카테고리의 다른 글
[Prism] <Control> ContentRegion (0) 2023.02.01 [Prism] Call Moule Class (0) 2023.02.01 [Prism] CompositeCommand (0) 2023.01.18 [Prism] Dynamic loading Modules (0) 2023.01.04 [Prism] 시작하기 (0) 2022.11.23 댓글