❔ PopupModal dialog not fadeout or fadein
Popup Modal not fadeout when click close button, or when open from menu
PopupModal.cs
using Kasir.Commons.Commands;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace Kasir.Utils.Controls
{
internal class PopupModal : ContentControl
{
event EventHandler PopupClosed;
public ICommand DismissCommand { get; }
static PopupModal()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PopupModal), new FrameworkPropertyMetadata(typeof(PopupModal)));
}
public PopupModal()
{
DismissCommand = new RelayCommand(Dismiss);
}
private void Dismiss(object view) => IsOpen = false;
public bool IsOpen
{
get { return (bool)GetValue(IsOpenProperty); }
set {
SetValue(IsOpenProperty, value);
if (!value) PopupClosed?.Invoke(this, EventArgs.Empty);
}
}
public static readonly DependencyProperty IsOpenProperty =
DependencyProperty.Register("IsOpen", typeof(bool), typeof(PopupModal), new PropertyMetadata(false));
public string Header
{
get { return (string)GetValue(HeaderProperty); }
set { SetValue(HeaderProperty, value); }
}
public static readonly DependencyProperty HeaderProperty =
DependencyProperty.Register("Header", typeof(string), typeof(PopupModal), new PropertyMetadata("Message Popup"));
}
}
using Kasir.Commons.Commands;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace Kasir.Utils.Controls
{
internal class PopupModal : ContentControl
{
event EventHandler PopupClosed;
public ICommand DismissCommand { get; }
static PopupModal()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PopupModal), new FrameworkPropertyMetadata(typeof(PopupModal)));
}
public PopupModal()
{
DismissCommand = new RelayCommand(Dismiss);
}
private void Dismiss(object view) => IsOpen = false;
public bool IsOpen
{
get { return (bool)GetValue(IsOpenProperty); }
set {
SetValue(IsOpenProperty, value);
if (!value) PopupClosed?.Invoke(this, EventArgs.Empty);
}
}
public static readonly DependencyProperty IsOpenProperty =
DependencyProperty.Register("IsOpen", typeof(bool), typeof(PopupModal), new PropertyMetadata(false));
public string Header
{
get { return (string)GetValue(HeaderProperty); }
set { SetValue(HeaderProperty, value); }
}
public static readonly DependencyProperty HeaderProperty =
DependencyProperty.Register("Header", typeof(string), typeof(PopupModal), new PropertyMetadata("Message Popup"));
}
}
3 Replies