using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;


namespace CustomControls
{
    /// <summary>
    /// Interakční logika pro PushButton.xaml
    /// </summary>
    public partial class PushButton : UserControl
    {
        public PushButton()
        {
            {
                InitializeComponent();
                LayoutRoot.DataContext = this;
            }
        }

        [Description("Text written on button"), Category("Data")]
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValueDp(TextProperty, value); }
        }

        [Description("Command for click event"), Category("Data")]
        public ICommand Command
        {
            get { return (ICommand)GetValue(CommandProperty); }
            set { SetValue(CommandProperty, value); }
        }

        [Description("Command parameter"), Category("Data")]
        public string CommandPar
        {
            get { return (string)GetValue(CommandParProperty); }
            set { SetValue(CommandParProperty, value); }
        }


        public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(object), typeof(PushButton));
        public static readonly DependencyProperty CommandParProperty = DependencyProperty.Register("CommadPar", typeof(object), typeof(PushButton));
        public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(PushButton));

        public event PropertyChangedEventHandler PropertyChanged;
        void SetValueDp(DependencyProperty property, object value, [System.Runtime.CompilerServices.CallerMemberName] string p = null)
        {
            SetCurrentValue(property, value);
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(p));
        }
    }
}
