Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <UserControl x:Class="VulcanGUI.UtilityDialogs.Views.ErrorDialog"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
  5. xmlns:prism="http://prismlibrary.com/"
  6. prism:ViewModelLocator.AutoWireViewModel="True"
  7. Height="200" Width="300">
  8. <Grid>
  9. <Grid.RowDefinitions>
  10. <RowDefinition Height="141*"/>
  11. <RowDefinition Height="59*"/>
  12. </Grid.RowDefinitions>
  13. <dx:SimpleButton Grid.Row="1" Content="OK" Command="{Binding OKCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}" HorizontalAlignment="Left" Height="39" Margin="83,10,0,0" VerticalAlignment="Top" Width="137" FontWeight="Bold" FontSize="20"/>
  14. <TextBlock Grid.Row="0" Text="{Binding Message}" TextAlignment="Center" HorizontalAlignment="Center" Margin="66,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="121" Width="224" FontWeight="Bold" FontSize="18"/>
  15. </Grid>
  16. </UserControl>
  17.  
  18. using System.Windows;
  19. using System.Windows.Input;
  20.  
  21. namespace VulcanGUI.UtilityDialogs.ViewModels
  22. {
  23. public class ErrorDialogViewModel : DialogViewModelBase
  24. {
  25. public ErrorDialogViewModel()
  26. {
  27. this.okCommand = new RelayCommand(OnOkClicked);
  28. }
  29.  
  30. private string _message;
  31. public string Message
  32. {
  33. get { return _message; }
  34. set
  35. {
  36. SetProperty(ref _message, value);
  37. }
  38. }
  39.  
  40. private ICommand okCommand = null;
  41. public ICommand OKCommand
  42. {
  43. get
  44. {
  45. return okCommand;
  46. }
  47.  
  48. set { okCommand = value; }
  49. }
  50.  
  51. private void OnOkClicked(object parameter)
  52. {
  53. CloseDialogWithResult(parameter as Window, DialogResult.Yes);
  54. }
  55. }
  56. }
  57.  
  58. using Prism.Mvvm;
  59. using System.Windows;
  60.  
  61. namespace VulcanGUI.UtilityDialogs
  62. {
  63. public abstract class DialogViewModelBase : BindableBase
  64. {
  65. public DialogResult UserDialogResult
  66. {
  67. get;
  68. set;
  69. }
  70.  
  71. public void CloseDialogWithResult(Window dialog, DialogResult result)
  72. {
  73. this.UserDialogResult = result;
  74. if (dialog != null)
  75. dialog.DialogResult = true;
  76. }
  77. }
  78. }
  79.  
  80. private void LoadJobErrorNotification(string errMsg)
  81. {
  82. var vm = new ErrorDialogViewModel() { Message = errMsg };
  83. var result = DialogService.OpenDialog(vm);
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement