System.Windows.Input.ICommand.Execute(object)

Here are the examples of the csharp api System.Windows.Input.ICommand.Execute(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

833 Examples 7

19 Source : SegmentedControl.cs
with MIT License
from 1iveowl

[EditorBrowsable(EditorBrowsableState.Never)]
        public void RaiseSelectionChanged()
        {
            OnSegmentSelected?.Invoke(this, new SegmentSelectEventArgs { NewValue = this.SelectedSegment });

            if (!(SegmentSelectedCommand is null) && SegmentSelectedCommand.CanExecute(SegmentSelectedCommandParameter))
            {
                SegmentSelectedCommand.Execute(SegmentSelectedCommandParameter);
            }
        }

19 Source : InvokeCommandAction.cs
with MIT License
from 1iveowl

public async Task<bool> Execute(object sender, object parameter)
        {
            if (Command is null)
            {
                return false;
            }
            
            object resolvedParameter;

            if (!(CommandParameter is null))
            {
                resolvedParameter = CommandParameter;
            }
            else if (!(Converter is null))
            {
                resolvedParameter = Converter.Convert(parameter, typeof(object), ConverterParameter, null);
            }
            else
            {
                resolvedParameter = parameter;
            }

            if (!Command.CanExecute(resolvedParameter))
            {
                return false;
            }

            Command.Execute(resolvedParameter);

            await Task.CompletedTask;

            return true;
        }

19 Source : CodeBoxControl.xaml.cs
with MIT License
from Abdesol

public void ButtonClicked(object sender, EventArgs e) => Command?.Execute(CommandParameter);

19 Source : SearchBarControl.xaml.cs
with MIT License
from Abdesol

private void InActivity(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Text))
            {
                if (OldText == Text)
                {
                    if (letsType)
                    {
                        OldText = "";
                        SearchedText = Text;
                        SearchCommand?.Execute(Text);
                        activityTimer.IsEnabled = false;
                    }
                }
                else
                {
                    if(SearchedText != Text) OldText = Text;
                    else
                    {
                        exitBtn.Visibility = Visibility.Visible;
                        circularBar.Visibility = Visibility.Hidden;
                    }
                }
            }
        }

19 Source : SearchBarControl.xaml.cs
with MIT License
from Abdesol

private void ClearClicked(object sender, EventArgs e)
        {
            searchBox.Text = "";
            SearchCommand?.Execute("");
            letsType = false;
        }

19 Source : SearchBarControl.axaml.cs
with MIT License
from Abdesol

private void InActivity(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Text))
            {
                if (OldText == Text)
                {
                    if (letsType)
                    {
                        OldText = "";
                        SearchedText = Text;
                        SearchCommand?.Execute(Text);
                        activityTimer.IsEnabled = false;
                    }
                }
                else
                {
                    if (SearchedText != Text) OldText = Text;
                    else
                    {
                        exitBtn.IsVisible = true;
                        circularBar.IsVisible = false;//Todo: maybe can be better "IsEnabled = false, Opacity = 0" .Visibility = Visibility.Hidden;
                    }
                }
            }
        }

19 Source : ExampleHelpers.cs
with MIT License
from ABTSoftware

private static void DoLoaded(object sender, EventArgs e)
        {
            TimedMethod.Invoke(() =>
            {
                var command = GetLoadedEventCommand((DependencyObject)sender);
                if (command != null)
                {
                    command.Execute(null);
                }
            }).After(200).Go();
        }

19 Source : ExampleHelpers.cs
with MIT License
from ABTSoftware

private static void OnUnloadedEventCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var fe = d as FrameworkElement;
            if (fe != null)
            {
                fe.Unloaded += (s, arg) =>
                {
                    var command = GetUnloadedEventCommand(fe);
                    if (command != null)
                    {
                        command.Execute(null);
                    }
                };
            }
        }

19 Source : EventToCommandBehavior.cs
with MIT License
from ABTSoftware

private void ExecuteCommand(object sender, EventArgs e)
        {
            object parameter = this.PreplacedArguments ? e : null;
            if (this.Command != null)
            {
                if (this.Command.CanExecute(parameter))
                    this.Command.Execute(parameter);
            }
        }

19 Source : InvokeCommandActionEx.cs
with MIT License
from ABTSoftware

protected override void Invoke(object parameter)
        {
            var eventArgs = parameter as SelectionChangedEventArgs;

            if (eventArgs != null)
            {
                var selectedSeries = (eventArgs.AddedItems.Count > 0 ? eventArgs.AddedItems[0] : null) as BaseRenderableSeries;

                if (selectedSeries != null && SnapToSelectedSeriesCommand != null)
                {
                    SnapToSelectedSeriesCommand.Execute(selectedSeries);
                }
            }
        }

19 Source : DigitalAnalyzerScrollBehavior.cs
with MIT License
from ABTSoftware

private void ScrollViewer_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                if (ChangeChannelHeightCommand?.CanExecute(null) != true) return;
                ChangeChannelHeightCommand.Execute(e.Delta > 0 ? ChannelHeightDelta : -ChannelHeightDelta);
                e.Handled = true;
            }
            else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                if (!(sender is ScrollViewer scroll)) return;
                scroll.ScrollToVerticalOffset(scroll.VerticalOffset - e.Delta);
                e.Handled = true;
            }
        }

19 Source : SignInView.vm.cs
with MIT License
from Accelerider

public void OnLoaded(SignInView view)
        {
            var preplacedwordBox = view.PreplacedwordBox;

            // 1. Login info from SignUpView
            if (_signUpArgs != null)
            {
                IsRememberPreplacedword = false;
                IsAutoSignIn = false;
                Email = _signUpArgs.Username;
                preplacedwordBox.Preplacedword = _signUpArgs.Preplacedword;

                SignInCommand.Execute(preplacedwordBox);
                _signUpArgs = null;
                return;
            }

            // 2. If there is some residual information on username or preplacedword text box, no login information is loaded from elsewhere.
            if (!string.IsNullOrEmpty(Email) || !string.IsNullOrEmpty(preplacedwordBox.Preplacedword)) return;

            // 3. No login info from config file.
            if (!CanSignIn(_settings.Username, _settings.Preplacedword)) return;

            // 4. Login info from config file.
            IsRememberPreplacedword = true;
            IsAutoSignIn = _settings.AutoLogin;
            Email = _settings.Username;
            preplacedwordBox.Preplacedword = _settings.Preplacedword.DecryptByRijndael();

            if (IsAutoSignIn)
            {
                SignInCommand.Execute(preplacedwordBox);
            }
        }

19 Source : SettingItem.xaml.cs
with MIT License
from Accelerider

private void SettingItem_OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (Command?.CanExecute(CommandParameter) ?? false) Command.Execute(CommandParameter);
        }

19 Source : SearchBar.xaml.cs
with MIT License
from Accelerider

private void PART_SearchBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            var text = PART_SearchBox.Text;
            if (IsRealTimeMode &&
               !string.IsNullOrEmpty(text) &&
               SearchCommand.CanExecute(text))
            {
                SearchCommand.Execute(text);
            }
        }

19 Source : CommandExtensions.cs
with MIT License
from Accelerider

public static void Invoke(this ICommand @this, object parameter = null)
        {
            if (@this != null && @this.CanExecute(parameter)) @this.Execute(parameter);
        }

19 Source : ExpressionEditorService.cs
with MIT License
from Actipro

private void OnEditorLostFocus(object sender, EventArgs e) {
			var editor = sender as IExpressionEditorInstance;
			if (editor != null)
				DesignerView.CommitCommand.Execute(editor.Text);
		}

19 Source : VideoPlayer.cs
with MIT License
from adamfisher

public void Play()
        {
            PlayCommand.Execute(null);
        }

19 Source : VideoPlayer.cs
with MIT License
from adamfisher

public void Pause()
        {
            PauseCommand.Execute(null);
        }

19 Source : VideoPlayer.cs
with MIT License
from adamfisher

public void Seek(int time)
        {
            SeekCommand.Execute(time.ToString());
        }

19 Source : EventToCommand.cs
with GNU General Public License v3.0
from aduskin

protected override void Invoke(object parameter)
        {
            if (replacedociatedElementIsDisabled() && !AlwaysInvokeCommand)
                return;
            var command = GetCommand();
            var parameter1 = CommandParameterValue;
            if (parameter1 == null && PreplacedEventArgsToCommand)
                parameter1 = EventArgsConverter == null
                    ? parameter
                    : EventArgsConverter.Convert(parameter, EventArgsConverterParameter);
            if (command == null || !command.CanExecute(parameter1))
                return;
            command.Execute(parameter1);
        }

19 Source : InvokeCommandAction.cs
with GNU General Public License v3.0
from aduskin

protected override void Invoke(object parameter)
        {
            if (replacedociatedObject == null)
                return;
            var command = ResolveCommand();
            if (command == null || !command.CanExecute(CommandParameter))
                return;
            command.Execute(CommandParameter);
        }

19 Source : CommandReference.cs
with GNU Affero General Public License v3.0
from akshinmustafayev

public void Execute(object parameter)
        {
            Command.Execute(parameter);
        }

19 Source : InfiniteScrollBehavior.cs
with GNU General Public License v3.0
from alexdillon

protected override void OnAttached()
        {
            base.OnAttached();

            Observable.FromEventPattern(this.replacedociatedObject, nameof(this.replacedociatedObject.LayoutUpdated))
                .Take(1)
                .Subscribe(_ =>
                {
                    var scrollViewer = this.replacedociatedObject.Scroll as ScrollViewer;

                    scrollViewer.GetObservable(ScrollViewer.VerticalScrollBarMaximumProperty)
                    .Subscribe(vscroll =>
                    {
                        this.verticalHeightMax = vscroll;

                        if (this.LockedToBottom)
                        {
                            // Scroll to bottom
                            scrollViewer.SetValue(ScrollViewer.VerticalScrollBarValueProperty, this.verticalHeightMax);
                        }
                    })
                    .DisposeWith(this.disposables);

                    scrollViewer.GetObservable(ScrollViewer.OffsetProperty)
                    .ForEachAsync(offset =>
                    {
                        if (scrollViewer.Extent.Height == 0)
                        {
                            this.LockedToBottom = scrollViewer.Bounds.Height == 0;
                        }

                        if (offset.Y <= double.Epsilon)
                        {
                            // At top
                            if (this.ReachedTopCommand.CanExecute(scrollViewer))
                            {
                                this.ReachedTopCommand.Execute(scrollViewer);
                            }
                        }

                        var delta = Math.Abs(this.verticalHeightMax - offset.Y);

                        if (delta <= double.Epsilon)
                        {
                            // At bottom
                            this.replacedociatedObject.SetValue(InfiniteScrollBehaviorPositionHelper.IsNotAtBottomProperty, false);
                            this.LockedToBottom = true;
                        }
                        else
                        {
                            // Not at bottom
                            this.replacedociatedObject.SetValue(InfiniteScrollBehaviorPositionHelper.IsNotAtBottomProperty, true);
                            this.LockedToBottom = false;
                        }
                    })
                    .DisposeWith(this.disposables);
                });
        }

19 Source : TextBoxSendBehavior.cs
with GNU General Public License v3.0
from alexdillon

private void replacedociatedObject_KeyDown(object sender, KeyEventArgs e)
        {
            var controlPressed = e.KeyModifiers.HasFlag(KeyModifiers.Control);
            var shiftPressed = e.KeyModifiers.HasFlag(KeyModifiers.Shift);

            if ((e.Key == Key.Enter || e.Key == Key.Return) &&
                (!controlPressed && !shiftPressed))
            {
                // Enter or Return has been pressed without any modifiers
                // Remove the newline character that Avalonia's textbox will automatically insert
                // Then, invoke send behavior
                var beforeCaret = this.replacedociatedObject.Text.Substring(0, this.replacedociatedObject.CaretIndex);
                var afterCaret = this.replacedociatedObject.Text.Substring(this.replacedociatedObject.CaretIndex);
                beforeCaret = beforeCaret.Substring(0, beforeCaret.LastIndexOf(this.replacedociatedObject.NewLine));
                var newString = $"{beforeCaret}{afterCaret}";
                this.replacedociatedObject.Text = newString;

                this.SendCommand?.Execute(null);
            }
            else if (e.Key == Key.Enter || e.Key == Key.Return)
            {
                // No special behavior is required. Enter has been pressed with a modifier key.
                // Allow Avalonia's TextBox to automatically handle newline insertion.
            }
        }

19 Source : LoginViewModel.cs
with GNU General Public License v3.0
from alexdillon

private async Task WaitForLogin()
        {
            var authKeyResult = await this.OAuthClient.GetAuthToken();
            this.OAuthClient.Stop();

            this.SettingsManager.CoreSettings.AuthToken = authKeyResult;
            this.SettingsManager.SaveSettings();

            this.LoginCompleted?.Execute(this);
        }

19 Source : GroupContentsControlViewModel.cs
with GNU General Public License v3.0
from alexdillon

private void PopoutMiniChat()
        {
            var windowService = Ioc.Default.GetService<IWindowService>();
            windowService.ShowWindow(new WindowParams()
            {
                Content = this,
                replacedle = this.replacedle,
                Width = 350,
                Height = 550,
                TopMost = true,
                StartingLocation = this.Settings.UISettings.MiniChatOpenLocation,
                StartingX = this.Settings.UISettings.MiniChatManualX,
                StartingY = this.Settings.UISettings.MiniChatManualY,
                Tag = this.Id,
                CloseCallback = () => this.CloseMiniChat?.Execute(this),
            });

            this.RegisterAsMiniChat.Execute(this);
            this.ShowDisplayOptions = false;
        }

19 Source : ListBoxExtensions.cs
with GNU General Public License v3.0
from alexdillon

private static void OnListBoxScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            var scrollViewer = (ScrollViewer)sender;
            var listBox = scrollViewer.TemplatedParent as ListBox;

            var topSnap = GetTopLoadingSnap(listBox);
            var bottomSnap = GetBottomLoadingSnap(listBox);

            if (bottomSnap > 0)
            {
                scrollViewer.UpdateLayout();
                scrollViewer.ScrollToVerticalOffset(bottomSnap);
                scrollViewer.UpdateLayout();
                SetBottomLoadingSnap(listBox, 0);
                return;
            }
            else if (topSnap != 0)
            {
                // Calculate the offset where the last message the user was looking at is
                // Scroll back to there so new messages appear on top, above screen
                scrollViewer.UpdateLayout();

                double newHeight = scrollViewer?.ExtentHeight ?? 0.0;
                double difference = newHeight - topSnap;

                scrollViewer.ScrollToVerticalOffset(difference);
                SetTopLoadingSnap(listBox, 0);
                return;
            }

            // Check to see if scrolled to top
            if (scrollViewer.VerticalOffset == 0)
            {
                var command = GetScrollToTop(listBox);
                if (command != null && command.CanExecute(null))
                {
                    // Save the original position to allow us to return to it when the UI update is completed
                    double originalHeight = scrollViewer?.ExtentHeight ?? 0.0;
                    double originalOffset = scrollViewer?.VerticalOffset ?? 0.0;

                    // Run the At-Top handler
                    scrollViewer.CanContentScroll = false;
                    SetTopLoadingSnap(listBox, (int)originalHeight);
                    command.Execute(scrollViewer);
                    scrollViewer.CanContentScroll = true;
                }
            }
            else if ((int)scrollViewer.VerticalOffset == (int)scrollViewer.ScrollableHeight)
            {
                if (e.VerticalChange < 1000)
                {
                    var command = GetScrollToBottom(listBox);
                    if (command != null && command.CanExecute(null))
                    {
                        // Save the original position to allow us to return to it when the UI update is completed
                        double originalHeight = scrollViewer?.ExtentHeight ?? 0.0;
                        double originalOffset = scrollViewer?.VerticalOffset ?? 0.0;

                        // Run the At-Bottom handler
                        scrollViewer.CanContentScroll = false;
                        SetBottomLoadingSnap(listBox, (int)originalOffset);
                        command.Execute(scrollViewer);
                        scrollViewer.CanContentScroll = true;
                    }
                }
            }
        }

19 Source : PopupViewModel.cs
with GNU General Public License v3.0
from alexdillon

private void CheckEasyCloseHandler(object e)
        {
            if (e is PointerPressedEventArgs pointerPressedEvent)
            {
                if (pointerPressedEvent.GetCurrentPoint(null).Properties.PointerUpdateKind == PointerUpdateKind.LeftButtonPressed)
                {
                    this.EasyClosePopup?.Execute(null);
                }
            }
        }

19 Source : DropDownButton.xaml.cs
with MIT License
from alexleen

private void AddAppenderItemOnClick(object sender, MouseButtonEventArgs e)
        {
            object dataContext = ((FrameworkElement)sender).DataContext;
            ItemClick?.Invoke(dataContext);
            Command?.Execute(dataContext);
        }

19 Source : FlexLayoutTappedBehavior.cs
with MIT License
from Altevir

private void OnTapped(object sender, EventArgs e)
        {
            if (sender is BindableObject bindable && this.Command != null && this.Command.CanExecute(null))
            {
                this.Command.Execute(bindable.BindingContext);
            }
        }

19 Source : ContentDialog.cs
with MIT License
from amwx

private void HandlePrimaryClick()
		{
			var ea = new ContentDialogButtonClickEventArgs(this);
			OnPrimaryButtonClick(ea);

			if (ea.Cancel)
				return;

			result = ContentDialogResult.Primary;
			if (!ea.IsDeferred)
			{
				if (PrimaryButtonCommand != null && PrimaryButtonCommand.CanExecute(PrimaryButtonCommandParameter))
				{
					PrimaryButtonCommand.Execute(PrimaryButtonCommandParameter);
				}
				HideCore();
			}
			else
			{
				IsEnabled = false;
			}
		}

19 Source : ContentDialog.cs
with MIT License
from amwx

private void HandleCloseClick()
		{
			var ea = new ContentDialogButtonClickEventArgs(this);
			OnCloseButtonClick(ea);

			if (ea.Cancel)
				return;

			result = ContentDialogResult.None;
			if (!ea.IsDeferred)
			{
				if (CloseButtonCommand != null && CloseButtonCommand.CanExecute(CloseButtonCommandParameter))
				{
					CloseButtonCommand.Execute(CloseButtonCommandParameter);
				}
				HideCore();
			}
			else
			{
				IsEnabled = false;
			}
		}

19 Source : MenuFlyoutItem.cs
with MIT License
from amwx

protected virtual void OnClick()
		{
			RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));

			if (Command?.CanExecute(CommandParameter) == true)
			{
				Command.Execute(CommandParameter);
			}
		}

19 Source : XamlUICommand.cs
with MIT License
from amwx

public void Execute(object param)
		{
			var args = new ExecuteRequestedEventArgs(param);

			ExecuteRequested?.Invoke(this, args);

			Command?.Execute(param);
		}

19 Source : ContentDialog.cs
with MIT License
from amwx

private void HandleSecondaryClick()
		{
			var ea = new ContentDialogButtonClickEventArgs(this);
			OnSecondaryButtonClick(ea);

			if (ea.Cancel)
				return;

			result = ContentDialogResult.Secondary;
			if (!ea.IsDeferred)
			{
				if (SecondaryButtonCommand != null && SecondaryButtonCommand.CanExecute(SecondaryButtonCommandParameter))
				{
					SecondaryButtonCommand.Execute(SecondaryButtonCommandParameter);
				}
				HideCore();
			}
			else
			{
				IsEnabled = false;
			}
		}

19 Source : Timeline.cs
with GNU General Public License v3.0
from AndreiFedarets

internal void OnOpenRequest(ISingleEventTree eventTree)
        {
            ICommand command = OpenCommand;
            if (command != null)
            {
                command.Execute(eventTree);
            }
        }

19 Source : ControlEventCommandBehavior.cs
with GNU General Public License v3.0
from AndreiFedarets

protected virtual void ExecuteCommand()
        {
            ExtendedCommandBase extendedCommandBase = Command as ExtendedCommandBase;
            if (extendedCommandBase != null)
            {
                extendedCommandBase.ExecuteInternal(CommandParameter);
            }
            else if (Command != null)
            {
                Command.Execute(CommandParameter);
            }
        }

19 Source : SwipeActionContextMenuView.cs
with MIT License
from AndreiMisiukevich

private void OnContextMenuOpened(BaseContextMenuView menuView)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                if (ContextMenu.IsAutoCloseEnabled)
                {
                    ContextMenu.ForceClose();
                }
                Moved?.Invoke(BindingContext);
                MovedCommand?.Execute(BindingContext);
            });
        }

19 Source : GridViewSorting.cs
with GNU General Public License v3.0
from AndreiFedarets

private static void OnColumnHeaderClick(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader;
            if (headerClicked != null)
            {
                string propertyName = GetPropertyName(headerClicked.Column);
                if (!string.IsNullOrEmpty(propertyName))
                {
                    ListView listView = GetAncestor<ListView>(headerClicked);
                    if (listView != null)
                    {
                        ICommand command = GetCommand(listView);
                        if (command != null)
                        {
                            if (command.CanExecute(propertyName))
                            {
                                command.Execute(propertyName);
                            }
                        }
                        else if (GetAutoSort(listView))
                        {
                            ApplySort(listView.Items, propertyName);
                        }
                    }
                }
            }
        }

19 Source : EventToCommandBehavior.cs
with MIT License
from AndyCW

void OnEvent(object sender, object eventArgs)
        {
            if (Command == null)
            {
                return;
            }

            object resolvedParameter;
            if (CommandParameter != null)
            {
                resolvedParameter = CommandParameter;
            }
            else if (Converter != null)
            {
                resolvedParameter = Converter.Convert(eventArgs, typeof(object), null, null);
            }
            else
            {
                resolvedParameter = eventArgs;
            }

            if (Command.CanExecute(resolvedParameter))
            {
                Command.Execute(resolvedParameter);
            }
        }

19 Source : Entry.cs
with MIT License
from angelobelchior

private void ExecuteCompletedCommand()
        {
            if (this.CompletedCommand != null)
                if (this.CompletedCommand.CanExecute(this.CompletedCommandParameter))
                    this.CompletedCommand.Execute(this.CompletedCommandParameter);
        }

19 Source : ListView.cs
with MIT License
from angelobelchior

private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (ItemTappedCommand != null && ItemTappedCommand.CanExecute(null))
                ItemTappedCommand.Execute(e.Item);
        }

19 Source : ListView.cs
with MIT License
from angelobelchior

private void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e)
        {
            var items = ItemsSource as IList;
            if (items != null && e.Item == items[items.Count - 3])
            {
                if (InfiniteScrollCommand != null && InfiniteScrollCommand.CanExecute(null))
                    InfiniteScrollCommand.Execute(null);
            }
        }

19 Source : Picker.cs
with MIT License
from angelobelchior

private void OnSelectedItemPropertyChanged()
        {
            if (this.ItemsSource == null) return;

            this.SelectedIndex = this.IndexOf(this.SelectedItem);
            if (this.SelectedItemChangedCommand != null && this.SelectedItemChangedCommand.CanExecute(this.SelectedItem))
                this.SelectedItemChangedCommand.Execute(this.SelectedItem);
        }

19 Source : EventToCommandBehavior.cs
with MIT License
from anjoy8

private void OnFired(object sender, EventArgs eventArgs)
        {
            if (Command == null)
                return;

            var parameter = CommandParameter;

            if (eventArgs != null && eventArgs != EventArgs.Empty)
            {
                parameter = eventArgs;

                if (EventArgsConverter != null)
                {
                    parameter = EventArgsConverter.Convert(eventArgs, typeof(object), EventArgsConverterParameter, CultureInfo.CurrentUICulture);
                }
            }

            if (Command.CanExecute(parameter))
            {
                Command.Execute(parameter);
            }
        }

19 Source : ControlDoubleClickBehavior.cs
with Apache License 2.0
from AnkiUniversal

static void control_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var control = sender as Control;
            
            if(control != null)
            {
                var command = control.GetValue(ExecuteCommand) as ICommand;
                var commandParameter = control.GetValue(ExecuteCommandParameter);

                if (command.CanExecute(e))
                {
                    command.Execute(commandParameter);
                }
            }
        }

19 Source : ContextMenuItem.cs
with MIT License
from anpin

internal void OnItemTapped()
        {

            ItemTapped?.Invoke(this, new EventArgs());
            if (Command?.CanExecute(CommandParameter) ?? false && IsEnabled)
            {
                Command.Execute(CommandParameter);
            }
        }

19 Source : WindowClosingBehaviour.cs
with MIT License
from AntonyCorbett

private static void OnWindowClosed(object? sender, EventArgs e)
        {
            var closed = GetClosed(sender as Window);
            closed?.Execute(null);
        }

19 Source : WindowClosingBehaviour.cs
with MIT License
from AntonyCorbett

private static void OnWindowClosing(object sender, CancelEventArgs e)
        {
            var closing = GetClosing(sender as Window);
            if (closing != null)
            {
                if (closing.CanExecute(null))
                {
                    closing.Execute(null);
                }
                else
                {
                    var cancelClosing = GetCancelClosing(sender as Window);
                    cancelClosing?.Execute(null);

                    e.Cancel = true;
                }
            }
        }

19 Source : WindowClosingBehaviour.cs
with MIT License
from AntonyCorbett

private static void OnWindowClosed(object sender, EventArgs e)
        {
            var closed = GetClosed(sender as Window);
            closed?.Execute(null);
        }

See More Examples