예제 #1
0
        /// <summary>
        /// Creates and initializes a new instance of the TwoButtonPopup class.
        /// </summary>
        public TwoButtonPopup()
        {
            _popUp = DependencyService.Get <ITwoButtonPopup>(DependencyFetchTarget.NewInstance);
            if (_popUp == null)
            {
                throw new InvalidOperationException("Object reference not set to an instance of a Popup.");
            }

            _popUp.BackButtonPressed += (s, e) =>
            {
                BackButtonPressed?.Invoke(this, EventArgs.Empty);
            };

            SetBinding(ContentProperty, new Binding(nameof(Content), mode: BindingMode.OneWayToSource, source: _popUp));
            SetBinding(FirstButtonProperty, new Binding(nameof(FirstButton), mode: BindingMode.OneWayToSource, source: _popUp));
            SetBinding(SecondButtonProperty, new Binding(nameof(SecondButton), mode: BindingMode.OneWayToSource, source: _popUp));
            SetBinding(TitleProperty, new Binding(nameof(Title), mode: BindingMode.OneWayToSource, source: _popUp));
            SetBinding(TextProperty, new Binding(nameof(Text), mode: BindingMode.OneWayToSource, source: _popUp));
        }