Questions tagged [icommand]

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

94 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
31votes
0answers
2kviews

Unit-Test project fails to build after installing .NET 4.5

I have a WPF solution in .NET 4.0 that includes a Unit Test project which tests the different commands used in the ViewModels. Everything was working fine, but then I installed .NET 4.5 and VS2012. ...
user avatar
  • 6,875
6votes
1answer
3kviews

MVVM Call Command from CommandBinding

I wanted to bind a CommandBinding to a ViewModel ICommand, this way, when the user hits Delete I can trigger my ViewModel's delete logic. The only way I know how to do it is in code behind, with this:...
user avatar
5votes
0answers
194views

Does WPF still leak on Custom ICommand implementations?

Before .Net 4.5, WPF controls used to leak on custom ICommand implementations that did not use a weak event pattern because they did not unsubscribe from the CanExecuteChanged event of the interface. ...
user avatar
  • 1,788
3votes
1answer
1kviews

Xamarin reusable xaml user control and custom command

first of all sorry for my english. I am working on a iOS and Android project using Xamarin.Form I would like to have a 'xaml user control' reusable in different way, and I need to make it clickable ...
user avatar
  • 33
2votes
1answer
1kviews

WPF MVVM Command CanExecute, reevaluates only at focus change

Refactoring an MVVM project in WPF, I'm trying to get rid of what seems a common problem between MVVM pattern users. I have view, who's DataContext is MyViewModel. Here is a button, bound with a ...
user avatar
2votes
1answer
1kviews

WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?

I'm trying to determine the best way to cause ICommands' CanExecute() to be reflected in the UI. I understand that the Dispatcher is the WPF (engine?) that handles UI drawing, and that by default, ...
user avatar
2votes
0answers
896views

WPF: can't pass System.Int32 as CommandParameter

I have a Button with an attached Command: <Button Command="{Binding Path=command}"> <Button.CommandParameter> <s:String>1</s:String> </Button....
user avatar
  • 1,701
2votes
1answer
290views

Raise context menu command's CanExcute while open the context menu

Can Execute of a ICommand while a Context menu open With the continuation of the above query, Still its not able to achieve. Is there any way to raise context menu command's CanExcute while open ...
user avatar
  • 2,485
2votes
1answer
642views

Where can I find the CommandTarget?

I am still making experiences with Commands and RoutedEvents. Without using RoutedCommands, I try to realize a ver simple program. Here is my Command class: public class ColorChanger : ICommand { ...
user avatar
2votes
2answers
78views

ViewModel in Class project

I'm building a WPF application which is based on the MVVM pattern. Later on we are going to build a Silverlight application of the same type, and also a Web application. I want to use my ...
user avatar
1vote
0answers
328views

WPF how to bind to the ICommand.CanExecute()

Basicaly I am facing very similar problem to the question WPF - how to hide menu item if command's CanExecute is false?, the accepted answer uses a clever workaround to bind to the IsEnabled instead ...
user avatar
  • 2,921
1vote
0answers
211views

Binding to existing Command from other location causes Data Error: 2

I have app, where some controls can 'publish' certain keybinding which in turn appears in context help, for example a button publishes F5 a keybinding: <Button Name="PublishKeybinding" Content="...
user avatar
  • 2,921
1vote
1answer
43views

In which context ICommand and Local:Mvx are prefered

I'm developing an Android application using Xamarin and MvvmCross. As seen in the layout posted at the bottom of this question I have a TextView and a Button. I want to achieve the following things: ...
user avatar
1vote
0answers
56views

UWP ICommand parameter always null

when trying to execute an ICommand, it always throws an exception due to the parameter being null. When I manually print the variable being passed to ICommand with Debug.WriteLine, it works perfectly....
user avatar
  • 59
1vote
2answers
50views

shifting code of code behind to viewmodel in wpf

Here is my code-behind: private void Button_Click(object sender, RoutedEventArgs e) { foreach (FrameworkElement fe in canvas.Children) { double ...
user avatar
1vote
1answer
610views

Can't set default value for ICommand of an DependencyProperty

I want to call an UserControl's Command from any viewmodel. I tried to bind to the Command in my view but it didn't work. (I don't have enough reputation to post images, so here is a link to the ...
user avatar
  • 903
1vote
0answers
656views

How can I use MVVM light to execute a Command on a text box text change event

I have installed MVVMLIGHT but still somehow I can't access EventToCommand property even after adding the reference files and using the namespaces in xaml file xmlns:i="http://schemas.microsoft....
user avatar
1vote
0answers
187views

NotifyPropertyChanged, view only updates when event bound to command

I am still fairly new to c# and WPF so perhaps this is expected but I find it strange and I can't seem to get around it. I have a window with an area to input information about an event and a submit ...
user avatar
  • 122
1vote
0answers
807views

WPF devexpress datagrid - CanExecute is not refreshed

I'm using devexpress datagrid to build my wpf application. I've very simple gird with 2 columns. Second column contains buttons with plus sign. Buttons are binded to Command in ViewModel (with ...
user avatar
  • 1,115
1vote
1answer
107views

How to make button bound to ICommand enable/disable when text changes, as opposed to losing focus of TextBox

I have a Windows Store XAML app with a "Save" button, which points to an ICommand property in my ViewModel. <Button Content="Save" Command="{Binding DataContext.SaveNewNote, ElementName=grid, ...
user avatar
  • 1,350
1vote
2answers
555views

Windows Phone - Binding TextBox or other control to CommandParameter of Button

I'm making my first steps into using Commands (by implementing the ICommand interface) in my Windows Phone applications. Now I've run into a problem I can't seem to figure out. I'm binding a control, ...
user avatar
  • 293
1vote
2answers
2kviews

Executing command in another viewmodel?

I have a custom "DateRangeSelector" control derived from ComboBox. This is a drop-down control with the following filters: 1. Today 2. Next three days 3. Next three weeks 4. Custom Range(Allows the ...
user avatar
  • 478
1vote
0answers
101views

DataGridCellTemplate bound to ViewModel command

for each cell in this column i want to bind a command from my view model , on each can execute of that command i wan't to send the "Entity" property of each item in my items source . DataGrid : ...
user avatar
  • 11.8k
1vote
1answer
777views

mvvm with prism: setting view from menu item

I am new to wpf world. I have a context menu in the shell as below: <ContextMenu> <MenuItem Header="Login" Command="{Binding ...
user avatar
1vote
1answer
715views

Can Execute of a ICommand while a Context menu open

A Control has its ContextMenu and its MenuItem is bound to an ICommand. ICommand's Can Execute has some code to enable and disable the MenuItem. This hits while loading and checks for Can Execute but ...
user avatar
  • 2,485
1vote
1answer
1kviews

MvvmCross, Xamarin Studio and ICommands

My issue was born in Does MvvmCross work in Xamarin Studio?. MvvmCross works fine in Visual Studio. However, I've been mandated to deploy this corporately using Xamarin Studio which is what their ...
user avatar
1vote
1answer
356views

How to continue routing with DelegateCommand in WPF

The KeyBindings in my application are stealing key down messages when I try to use the textbox. So for example: <ribbon:RibbonWindow.InputBindings> <KeyBinding Command="{Binding Review....
user avatar
  • 1,258
1vote
1answer
405views

Tunneling Commands

I have several user controls which are instantiated in a ListBox. I have a button in my Window which raises NavigationCommands.Refresh, and a CanExecute handler to allow it to execute: <Window....
user avatar
  • 9,779
1vote
2answers
469views

Simplifying ICommand/RelayCommand in a MVVM approach

I'm pushing myself to make the applications I write simpler, and I've taken some steps to do that, but I'm left with an interesting problem that doesn't at all feel like it would be unique to me. I'm ...
user avatar
  • 97
0votes
1answer
44views

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 ...
user avatar
0votes
0answers
43views

How WPF Interaction.Behaviors/EventTrigger updates the UI in WPF?

I have a WPF application with a custom UserControl and I want to respond to a mouse event by using a simple EventTrigger from the Microsoft.Xaml.Behaviors library. I also have a canvas which needs to ...
user avatar
  • 4,083
0votes
0answers
106views

How to add a button with a click event as a WPF listview item in Powershell

So my Template is as follow: <ListView Name="ListViewMonitors" Margin="10,46,10,10" Background="#FFEFEBDE" FontWeight="Bold" Foreground="Black"> ...
user avatar
0votes
0answers
36views

How to hide the menu context ,when datagrid id empty in wpf?

When i click on empty grid , the context menu still appears with it's row based options. How can I only have the context menu appear when the datagrid contain atleast 1 element? What i have tried i am ...
user avatar
0votes
0answers
22views

ICommand.Execute open new process

I'vw just met problem in clients application. They use oledb and when ICommand.execute method calling for "alter database..." SQL Server open new process. How prevent this ? Can I make it in ...
user avatar
  • 1
0votes
2answers
66views

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; ...
user avatar
  • 472
0votes
0answers
17views

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 ...
user avatar
  • 1
0votes
0answers
187views

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 ...
user avatar
  • 11
0votes
3answers
984views

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</...
user avatar
  • 1,301
0votes
0answers
32views

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) => { ...
user avatar
  • 385
0votes
1answer
363views

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 ...
user avatar
0votes
1answer
451views

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:...
user avatar
  • 819
0votes
0answers
81views

.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()), ...
user avatar
0votes
0answers
313views

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; ...
user avatar
0votes
0answers
48views

Send Text value from 2 Labels using Command inside BindableLayout

I'm working with MVVM and I have a bindablelayout like this: <StackLayout Margin="20" BindableLayout.ItemsSource="{Binding MyApartments}" > <BindableLayout.ItemTemplate> &...
user avatar
  • 109
0votes
1answer
69views

Validating Grid Rows on button click using custom ICommand implementation - WPF

I want to validate my DataGrid rows for errors, and if there are any errors present then the 'Save' button should be disabled or at least there should be some message saying there are errors. After ...
user avatar
  • 2,069
0votes
0answers
89views

How to use MultiBinding in WPF

I would like to pass two text parameters when a button is clicked. I used MultiBinding and that partially works but something's not quite right yet. Converter: public object Convert(object[] values,...
user avatar
0votes
1answer
184views

Unit testing ICommand.CanExecute when using CommandManager

(Part of) my ICommand implementation is: public void RaiseCanExecuteChanged() { CommandManager.InvalidateRequerySuggested(); } public event EventHandler CanExecuteChanged ...
user avatar
  • 2,057
0votes
2answers
1kviews

WPF MVVM - Simple Binding Button with Textbox (Icommand)

What I'm trying to do is: when the textbox contains the value "123" it should enable the button and allow me to click it. Solution Image & View Image I can not find a way to trigger the Button ...
user avatar
0votes
0answers
342views

MRU Menu with Fluent.Ribbon - Can't wire Command to ModelView

I'm new to WPF and am trying to build an MRU (most recently used items) menu with the Fluent.Ribbon library. Some digging in example code and the internet lead me to this point where I can generate ...
user avatar
  • 1,756

15 30 50 per page