Я пишу кассовую систему и хочу открыть окно оплаты, где вы завершаете платеж, но при попытке открыть окно выдает ошибку System.ArgumentException: 'Must disconnect specified child from current parent Visual before attaching to new parent Visual.'
, когда я нажимаю кнопку, чтобы открыть новое окно. вот мой код:
private void PaymentButton_Click(object sender, RoutedEventArgs e)
{
if (!PaymentWindowOpen)
{
PaymentWindow Window = new PaymentWindow(this);
Window.Show();//this is where the error shows
PaymentWindowOpen = true;
}
}
Это код кнопки. Вот код для класса окна оплаты:
public partial class PaymentWindow : Window
{
public MainWindow mainWindow = new MainWindow();
public PaymentWindow(MainWindow mainWindow)
{
InitializeComponent();
this.mainWindow = mainWindow;
PaymentPrice.Content = mainWindow.ActualTotal;
}
private void FiverButton_Click(object sender, RoutedEventArgs e)
{
}
}
}
Игнорируйте пустой метод, заранее спасибо за любую помощь