Questions tagged [icommand]

Interface for MVVM scenarios in Silverlight and WPF to bind commands from models to controls (Buttons).

Filter by
Sorted by
Tagged with
-1 votes
1 answer
22 views

WPF Custom Control with buttons

I have created a WPF custom control for my application. I am now struggling to wire up the events for some of the controls in the control (ToggleButtons). I have defined the following: WindowHeader....
Richard Gale's user avatar
  • 1,816
0 votes
1 answer
43 views

DatePicker ICommand executed multiple times

I have a DatePicker with an ICommand which perform certain tasks. For some reason when I select a date, the VM.SetPreviousDate() method is called multiple times when the Icommand is executed (at least ...
May Nguyen's user avatar
0 votes
1 answer
82 views

Command for DatePicker in WPF project

I'm working on a WPF project using MVVM and I want to create a command for a DatePicker but I have no luck. I have this setup but it doesn't trigger the command on Date selection. What I want to do is ...
May Nguyen's user avatar
1 vote
1 answer
116 views

Why is the ICommand not triggered in my MAUI app?

At the XAML I got a button using a command: <Button Text="Month" Command="{Binding SetMonthCommand}"/> At the ViewModel class I implement the Command: public ICommand ...
Frank Mehlhop's user avatar
1 vote
0 answers
47 views

Navigation command works when called by button but not when called programmatically

I have a WPF app which has two User Controls. On one user control, I have a list of buttons which are all binded to a command that changes the ViewModel from that user control to the other, with a ...
Ethan Shoe's user avatar
1 vote
1 answer
817 views

.NET MAUI pass picker value to ICommand

I'm a beginner with .NET MAUI and I'm trying to pass a Picker value to an Icommand, but what I can receive is only this date 01/01/1900 The Icommand is fired but the date still 01/01/1900 This is my ...
Orion77's user avatar
  • 92
-1 votes
2 answers
185 views

C# WPF Declare an ICommand in a single line

I'm in the process of learning WPF and the MVVM design pattern. Currently the code in my ViewModel for a delete customer command looks like this: public class vmCustomers : INotifyPropertyChanged ...
Mark Roworth's user avatar
-1 votes
2 answers
82 views

CurrentViewModel Property Change Not Reflected in ContentControl

Hello I have looked everywhere and I can't understand what I am doing wrong. My command is called and the onpropertychanged event is called but the ContentControl in my MainWindow will not show the ...
Hack.Sign's user avatar
0 votes
1 answer
87 views

Dependency Property command's CanExecute() not updating

I have a user control and within I defined the following property: public string MyProperty { get { return (string)GetValue(MyPropertyProperty); } set { SetValue(MyPropertyProperty, value);...
Anno's user avatar
  • 781
1 vote
0 answers
12 views

MVVM AsyncExecute causing lag

AsyncExecute method causing lag in my treeview application when I am expanding a branch. Important parts of my TreeView public DirectoryItemViewModel(string fullPath, DirectoryItemType type, long size)...
Palamar66's user avatar
  • 222
-1 votes
1 answer
122 views

How to implement CanExecuteChanged on Commands which can always be executed

Let's say you want to create an ICommand that can always be executed. Then it's canExecute method should always return true. And the CanExecuteChanged event is basically not very useful. In my mind it ...
Boris Month's user avatar
-1 votes
1 answer
85 views

wpf The relayCommand needs a constractor that takes parameter

my goal is filter a dataGrid with a textbox input, so i have textbox to filter a datagrid. for all the other commands i used one of these constractors in my **relayCommand ** as follows: // ...
farzadwpf's user avatar
0 votes
1 answer
364 views

Relay Command CanExecute is only invoked in the viewmodels constuctor once but won't invoke again when Properties are changed

What I want to do: When my view is loaded, one can see several textboxes that are compulsory fields(marked red). For as long as those textboxes are not filled out, the button "NEXT" is ...
timunix's user avatar
  • 609
0 votes
0 answers
20 views

Navigate to a new window on item click in ItemTemplate in WPF [duplicate]

I have created a Grid with ItemTemplate and now on click of any item I want user to navigate to new screen. I have added ICommand function in ViewModel for this but I am not able to handle the Command ...
Panks's user avatar
  • 567
0 votes
1 answer
188 views

HttpClient.GetAsync not re-enabling the button MVVM

Solved: See below. Update: This fails on the HttpClient.GetAsync. It's like a "Task Finished" event isn't listened to. I'm suspecting a threading problem. It manifests itself as the ...
Ray Brennan's user avatar
0 votes
2 answers
368 views

WPF - Connect EventSetter to an ICommand

I'm looking for a solution where I double click on a DataGridRow that calls a method in my ViewModel with an ICommand. I have this code for my DataGrid's DataGridRow style: <DataGrid.Resources> ...
Mc_Topaz's user avatar
  • 597
-1 votes
1 answer
165 views

How to bind a ICommand into a Button out of DataContext?

i have a Button into a DataGrid with a DataContext (KeyValuePair). I want to implementing a Command into this Button. But if i use the Command="{Binding CommandoTest}" it didnt work. I ...
MalinaStempel's user avatar
0 votes
1 answer
202 views

WPF ICommands Binding

I am continuing my exploration of WPF and trying to follow MVVM with Commands. My simple code is as follow. MainWindow.xaml <Window x:Class="ClickCommand.MainWindow" xmlns="...
StephenH's user avatar
0 votes
1 answer
100 views

If dependency property is true, then ICommand property should execute

Ok, I have the custom control with its style and the view model with the ICommand property in the different files. CustomControl.cs public class CustomButtons: Control { public static readonly ...
Manav Mehta's user avatar
0 votes
2 answers
116 views

Disable CanExecute on switching views

I have a static property which tracks property changes in my viewmodels: public static class Global { public static int Warning { get { return _warning; } set { _warning = value; ...
Lucy82's user avatar
  • 652
0 votes
1 answer
536 views

WPF - MVVM - View doesn't update when changing properties of a VM instance

I'm fairly new to MVVM and WPF so take everything what I'm saying with a grain of salt. My problem is quite complex and I've been trying to find a solution for the past day now. To no avail... Context ...
Florianvdab's user avatar
0 votes
0 answers
32 views

Add UIElement to the MainWindow with ICommand C#

I would like to add dinamically UIElement through ICommand. It is working fine with EventHandler but when I try to do the same using ICommand the UIElement is invisible however it seams the stackpanel ...
Milán's user avatar
  • 1
0 votes
0 answers
364 views

Carousel View in Xamarin forms not responding to Image button in the view

I cannot get the image buttons to move the carousel image to the next in the list. when I click the imagebutton and step through the code the Position is changing properly, but does not move the ...
marcusC's user avatar
  • 11
0 votes
1 answer
40 views

is it possible to create an invisible xaml command always set to true?

I am working with a window and I would like to create a command that is invisible (or virtual, I am not sure about how it is called) and always checks itself (always true during runtime). This way I ...
Josh.h's user avatar
  • 71
0 votes
1 answer
116 views

WPF ObservableCollection & InotifyPropertyChanged [duplicate]

the model class represents the database. I pull the data from the database in the viewmodel and display it in the datagrid. When I change the corresponding cell in the datagrid, this change is not ...
Fatih Kundak's user avatar
1 vote
1 answer
265 views

React to updates on ObservableCollection

I have the following piece of code: ReactiveCommand .CreateFromTask(_ => GetPerson()) .Execute() .Subscribe(x => person = x); var canNext = person?.Friends ....
Kyle Grierson's user avatar
0 votes
1 answer
839 views

Passing a parameter to RelayCommand

I'm experimenting with the ICommand and RelayCommand constructs. Looking around, I've put together the following code: public class RelayCommand : ICommand { private Action<object> ...
Giovanni Nieddu's user avatar
1 vote
3 answers
3k views

Blazor - How to execute the form submit in Button click using ICommand

How to execute the form submit in Button click using ICommand How to pass parameter in ICommand execute @using System.Windows.Input <button @onclick="buttonClick"> Blazor Button</...
M K's user avatar
  • 1,831
0 votes
1 answer
488 views

wpf-mvvm how can i validate my data with icommand?

I'm new to WPF development and I don't get any further with google either. I don't understand how I can validate my model data with ICommand. I understand that there are annotations and that the ...
TheWorldDrown's user avatar
0 votes
1 answer
59 views

Cannot bind value with command parameter

I need get the Text value from TextBox tag in my SubmitCommand but I only get an empty value. Please help me find out what I need to do for to display the text in my MessageBox. <UserControl> ...
Ros97's user avatar
  • 61
0 votes
1 answer
259 views

Xamarin: Grouped ListView not binding delete Command using MVVM

I'm getting crazy trying to bind a Command in order to remove an item from a grouped ListView. My ViewModels inherit from a BaseViewModel in order to ease the notification of a changing property. I ...
exrezzo's user avatar
  • 497
0 votes
1 answer
302 views

Custom event in custom view model binding

I have searched far and wide. My problem is, that I can’t find a solution to this very simple problem of mine. I have a page, which hosts a data grid. The goal is to have the name in the data grid ...
Weirdmind's user avatar
0 votes
0 answers
54 views

Is there a way to be notified when an ICommand is executed?

Here is my code: var viewModel = factory.Create(); var commandBinding = new CommandBinding(viewModel.Command, (target, e) => { ...
PlaTyPuS's user avatar
  • 385
0 votes
3 answers
780 views

WPF EventHandler for TextBox.TextChanged in XAML or code behind?

Description In WPF, using MvvmLight, I have a viewModel with an integer property SelectedIndex. Changing the value of this property is an expensive operation, so I only want to update the property if ...
Harald Coppoolse's user avatar
2 votes
4 answers
1k views

WPF: Update button if text in TextBox changes

To learn WPF Command and CommandParameter I have a small WPF application with one TextBox and one Button. Whenever the button is pressed, ICommandTest should be called with the text of the text box as ...
Harald Coppoolse's user avatar
0 votes
1 answer
1k views

How to get property and call command from different ViewModel with mvvm pattern

I have a ViewModel with all the properties that i will need in every sub ViewModel. It's the first time i try to split commands and viewmodel to multiple files. Last time everything was in the same ...
MoneyMaker's user avatar
0 votes
1 answer
225 views

UWP - Command parameters are empty

I'm using RelayCommand which is implemented by Microsoft in their ICommand example. Here is a brief of my code. XAML: <TextBox x:Name="YoutubeUrlText" PlaceholderText="...
Kafka Wanna Fly's user avatar
0 votes
2 answers
196 views

WPF ICommand equivalent of Click -= Button_Click

For WPF ICommand, what is the equivalent of the event handler -=? We have a user control button that manages the function of submitting a purchase request but requires a user to register on the ...
Galactic's user avatar
  • 410
0 votes
1 answer
70 views

Command CanExecute not changing

This example isn't supposed to make sense, i'm just practicing. I have this command: public class NewCommand : ICommand { public event EventHandler CanExecuteChanged ...
AdmiralCat3's user avatar
1 vote
1 answer
427 views

ICommand is not executed in WPF application

I have a WPF application with a button which I bind to MessageCommand. In order to make it simple, the app only has a button which should display a messagebox. However, when I click the button, ...
Alex_P's user avatar
  • 2,590
0 votes
0 answers
43 views

WPF CommandParameter value is changing to null on execution [duplicate]

I am studying C# WPF and at the moment I am facing an issue. The app: I am playing around with the MVVM pattern. I have built a simple application that includes just -a ListView that displays a ...
Efthymios's user avatar
  • 253
1 vote
2 answers
1k views

Unit Testing ICommand and Methods

I have developed an WPF application using MVVM as a architecture and am writing some unit tests as part of this. In my view I have a button that is bound to a property in the ViewModel which can be ...
user avatar
0 votes
1 answer
2k views

Why is the WPF ApplicationCommands.Close command disabled on the button and in the menu item?

Question Why is the WPF ApplicationCommands.Close command disabled on the button and in the menu item? Code <Window x:Class="ApplicationCloseCommand.Views.MainWindow" xmlns="http://...
Lernkurve's user avatar
  • 20.3k
0 votes
1 answer
572 views

Xamarin Forms Command always null in custom control

I try to create a usercontrol. The user control will be a Button to show loader. I try to pass a binded command from my page to my control My XAML PAge is: <sharedviews:...
dalton5's user avatar
  • 915
0 votes
1 answer
301 views

WPF: ICommand, open a txt file in textbox

I have a little problem here , I have to open (read) a text file in a basic WPF notepad kind thing , but i have to do with ICommand interface. The problem is that when i chose the txt file i want to ...
Tibor's user avatar
  • 25
0 votes
1 answer
507 views

Fire and forget?

I have a asyncRelayCommand in a c# wpf mvvm application that does not work i kinda understand that i need a method for this but the guide i went through does not mention how to make one https://...
user avatar
1 vote
2 answers
2k views

WPF binding command to Datacontext inside Datagrid

I am just getting started with WPF and MVVM and managed to bind my Datagrid to the list ProductList of my DataContext ViewModel Class. However, I am now trying to bind the buttons inside my DataGrid ...
Randy Quackers's user avatar
0 votes
0 answers
117 views

.Net C# Dependency Injection resolve ICommands same type

I have a class with many ICommands in the constructor parameters. var classWithManyCommands = new ClassWithManyCommands(new AddItemsCommand(new StringService()), ...
TomatenSalat's user avatar
0 votes
1 answer
58 views

Command Bindings don't work with 2nd window/ view

I have a WPF-Application with two windows as Views (MVVM). With the first one binding of commands works out quite fine though with the 2nd view commands don't trigger (both windows access the same ...
Rob's user avatar
  • 57
1 vote
0 answers
960 views

How correctly implement ICommand in WPF using MVVM pattern?

I`m trying to do a simple WPF application using MVVM pattern. I wrote a class implementing ICommand interface: public class RelayCommand : ICommand { private Action<object> execute; ...
Николай Деркач's user avatar

1
2 3 4 5
10