diff --git a/Correlator/ViewModels/PictureFileViewModel.cs b/Correlator/ViewModels/PictureFileViewModel.cs index 28a107b..2932f7f 100644 --- a/Correlator/ViewModels/PictureFileViewModel.cs +++ b/Correlator/ViewModels/PictureFileViewModel.cs @@ -62,6 +62,7 @@ public DelegateCommand GoBackCommand { get; set; } public DelegateCommand ItemSelectedCommand { get; set; } + public DelegateCommand ShowPictureCommand { get; set; } public DelegateCommand DeleteItemCommand { get; set; } public DelegateCommand ReLoadDataCommand { get; set; } public DelegateCommand> PageUpdatedCmd { get; set; } @@ -70,7 +71,7 @@ private ImageResultFile _selectedFile; - public PictureFileViewModel() + public PictureFileViewModel(IDialogService dialogService) { GoBackCommand = new DelegateCommand(delegate { @@ -82,6 +83,12 @@ _selectedFile = (ImageResultFile)dataGrid.SelectedItem; }); + ShowPictureCommand = new DelegateCommand(delegate(string fullPath) + { + dialogService.ShowDialog("BigPictureView", + new DialogParameters { { "ImageFullPath", fullPath } }, delegate { }); + }); + DeleteItemCommand = new DelegateCommand(() => { if (_selectedFile == null) diff --git a/Correlator/ViewModels/PictureFileViewModel.cs b/Correlator/ViewModels/PictureFileViewModel.cs index 28a107b..2932f7f 100644 --- a/Correlator/ViewModels/PictureFileViewModel.cs +++ b/Correlator/ViewModels/PictureFileViewModel.cs @@ -62,6 +62,7 @@ public DelegateCommand GoBackCommand { get; set; } public DelegateCommand ItemSelectedCommand { get; set; } + public DelegateCommand ShowPictureCommand { get; set; } public DelegateCommand DeleteItemCommand { get; set; } public DelegateCommand ReLoadDataCommand { get; set; } public DelegateCommand> PageUpdatedCmd { get; set; } @@ -70,7 +71,7 @@ private ImageResultFile _selectedFile; - public PictureFileViewModel() + public PictureFileViewModel(IDialogService dialogService) { GoBackCommand = new DelegateCommand(delegate { @@ -82,6 +83,12 @@ _selectedFile = (ImageResultFile)dataGrid.SelectedItem; }); + ShowPictureCommand = new DelegateCommand(delegate(string fullPath) + { + dialogService.ShowDialog("BigPictureView", + new DialogParameters { { "ImageFullPath", fullPath } }, delegate { }); + }); + DeleteItemCommand = new DelegateCommand(() => { if (_selectedFile == null) diff --git a/Correlator/Views/PictureFileView.xaml b/Correlator/Views/PictureFileView.xaml index 040e7bc..a50dc31 100644 --- a/Correlator/Views/PictureFileView.xaml +++ b/Correlator/Views/PictureFileView.xaml @@ -111,9 +111,15 @@ HorizontalAlignment="Left" Background="Transparent" BorderThickness="0" - Click="ShowPictureButton_OnClick" - Style="{x:Null}" - Tag="{Binding FullPath}"> + Command="{Binding DataContext.ShowPictureCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" + CommandParameter="{Binding FullPath}" + Style="{x:Null}"> + + + diff --git a/Correlator/ViewModels/PictureFileViewModel.cs b/Correlator/ViewModels/PictureFileViewModel.cs index 28a107b..2932f7f 100644 --- a/Correlator/ViewModels/PictureFileViewModel.cs +++ b/Correlator/ViewModels/PictureFileViewModel.cs @@ -62,6 +62,7 @@ public DelegateCommand GoBackCommand { get; set; } public DelegateCommand ItemSelectedCommand { get; set; } + public DelegateCommand ShowPictureCommand { get; set; } public DelegateCommand DeleteItemCommand { get; set; } public DelegateCommand ReLoadDataCommand { get; set; } public DelegateCommand> PageUpdatedCmd { get; set; } @@ -70,7 +71,7 @@ private ImageResultFile _selectedFile; - public PictureFileViewModel() + public PictureFileViewModel(IDialogService dialogService) { GoBackCommand = new DelegateCommand(delegate { @@ -82,6 +83,12 @@ _selectedFile = (ImageResultFile)dataGrid.SelectedItem; }); + ShowPictureCommand = new DelegateCommand(delegate(string fullPath) + { + dialogService.ShowDialog("BigPictureView", + new DialogParameters { { "ImageFullPath", fullPath } }, delegate { }); + }); + DeleteItemCommand = new DelegateCommand(() => { if (_selectedFile == null) diff --git a/Correlator/Views/PictureFileView.xaml b/Correlator/Views/PictureFileView.xaml index 040e7bc..a50dc31 100644 --- a/Correlator/Views/PictureFileView.xaml +++ b/Correlator/Views/PictureFileView.xaml @@ -111,9 +111,15 @@ HorizontalAlignment="Left" Background="Transparent" BorderThickness="0" - Click="ShowPictureButton_OnClick" - Style="{x:Null}" - Tag="{Binding FullPath}"> + Command="{Binding DataContext.ShowPictureCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" + CommandParameter="{Binding FullPath}" + Style="{x:Null}"> + + + diff --git a/Correlator/Views/PictureFileView.xaml.cs b/Correlator/Views/PictureFileView.xaml.cs index d1cb42a..a67c870 100644 --- a/Correlator/Views/PictureFileView.xaml.cs +++ b/Correlator/Views/PictureFileView.xaml.cs @@ -1,25 +1,12 @@ -using System.Windows; -using System.Windows.Controls; -using Prism.Services.Dialogs; +using System.Windows.Controls; namespace Correlator.Views { public partial class PictureFileView : UserControl { - private readonly IDialogService _dialogService; - - public PictureFileView(IDialogService dialogService) + public PictureFileView() { InitializeComponent(); - - _dialogService = dialogService; - } - - private void ShowPictureButton_OnClick(object sender, RoutedEventArgs e) - { - var fullPath = (sender as Button)?.Tag.ToString(); - _dialogService.ShowDialog("BigPictureView", - new DialogParameters { { "ImageFullPath", fullPath } }, delegate { }); } } } \ No newline at end of file