Code: Select all
EditClipboardTextCommand
Code: Select all
private void MinimizeApplication()
{
Logger.Debug("Minimizing application.");
if (viewModel is not
{
IsSettingsWindowOpen: false, IsClearAllHistoryWindowOpen: false, IsClearAllHistoryWindowOpen: false
}) return;
Hide();
WindowState = WindowState.Minimized;
}
< /code>
Wiederherstellung der Anwendung aus der Systemschale (MainWindow.xaml.cs
Code: Select all
private void MaximizeApplication()
{
Logger.Debug("Maximizing application.");
if (WindowState != WindowState.Normal)
{
SetWindowsLocation();
Show();
Logger.Debug("Restore the window if it's minimized.");
WindowState = WindowState.Normal;
Logger.Debug("Bring the window to the foreground.");
this.Activate();
Logger.Debug("Temporarily set the window as topmost.");
this.Topmost = true;
this.Topmost = false;
}
else
BringApplicationTtoTheFront();
isApplicationOnFocus = true;
}
private void BringApplicationTtoTheFront()
{
Logger.Debug("Bringing application to the front.");
this.Activate();
this.Topmost = true;
this.Topmost = false;
this.Focus();
}
< /code>
ListView -Element mit einer Schaltfläche (Schaltfläche (MainWindow.xaml
Code: Select all
< /code>
Einstellen einer Referenz auf das Hauptfenster (MainWindow.xaml.cs
Code: Select all
public MainWindow()
{
// Set reference to main window in the application.
ReferenceClass.MainWindow = this;
}
using ClipKeeper.Forms;
using ClipKeeper.Source.MVVM.Model;
using ClipKeeper.Source.MVVM.ViewModel;
using ClipKeeper.Source.Utils;
using System;
using System.Windows.Input;
namespace ClipKeeper.Source.Commands
{
internal class EditClipboardTextCommand : ICommand
{
public event EventHandler? CanExecuteChanged;
public BaseViewModel ViewModel { get; set; }
public EditClipboardTextCommand(BaseViewModel viewModel)
{
ViewModel = viewModel;
}
public bool CanExecute(object? parameter)
{
return true;
}
public void Execute(object? parameter)
{
if (parameter is ClipboardItem clipboardItem)
{
EditTextWindow editTextWindow = new EditTextWindow(clipboardItem);
editTextWindow.Owner = ReferenceClass.MainWindow;
ReferenceClass.EditTextWindow = editTextWindow;
ViewModel.EditClipboardTextWindowOpen = true;
editTextWindow.ShowDialog();
ViewModel.EditClipboardTextWindowOpen = false;
}
}
}
}
< /code>
Zusätzliche Details: < /strong>
Die Befehlsbindung funktioniert vor dem Minimieren, funktioniert jedoch nicht mehr nach der Wiederherstellung der Systemschale.
Andere UI -Elemente in der ListViewItem < /code> Bleiben Sie interaktiv.EditTextWindow< /code>).
Was ich ausprobiert habe:
Überprüfen . Was könnte dazu führen, dass die Befehlsbindung der Schaltfläche nach dem Minimieren und Wiederherstellen des Systemschalens nicht mehr funktioniert?
Wie kann ich sicherstellen>