icommand

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

核能气质少年 提交于 2019-12-24 03:10:38
问题 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, the Dispatcher evaluates ICommands' CanExecute() method upon instantiation as well as active user interface (clicking the UI, or keyboard input.) Obviously, this is a problem when CanExecute() on any given ICommand changes, but neither mouse nor keyboard input is provided--and so the UI does not

Button using ICommand does not get disabled?

六眼飞鱼酱① 提交于 2019-12-24 00:57:03
问题 I have a button control in my wpf-mvvm application. I use an ICommand property (defined in viewmodel) to bind the button click event to viewmodel. I have -> execute and canexecute parameters for my ICommand implementation ( RelayCommand ). Even if CanExecute is false...button is not disabled...WHEN button CONTENT is IMAGE But, when button content is text..enable/disable works fine. <Button DockPanel.Dock="Top" Command="{Binding Path=MoveUpCommand}"> <Button.Content> <Image Source="/Resources

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

浪尽此生 提交于 2019-12-23 23:00:10
问题 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 the context menu. This need to be done in the context menu itself and here am not able to access the viewmodel. Any idea on this? public static BaseCommand SaveCommand { get { if (saveCommand == null) saveCommand = new BaseCommand(OnSaveCommandClicked, OnSaveCommandCanExcute); return saveCommand; } }

Is it possible to take advantage of the ICommand in an ASP.NET MVC project?

女生的网名这么多〃 提交于 2019-12-23 12:48:18
问题 Basically, I am creating a portable class library, and creating a bunch of ViewModels: public class CustomerViewModel : ViewModelBase { public string FirstName { ... } // INPC public string LastName { ... } // INPC public string FullName { get { return FirstName + " " + LastName; } } public ICommand DoFooCommand { get; private set; } // DelegateCommand private bool CanDoFoo(object parameter) { ... } private void DoFoo(object parameter) { ... } } This is great if I want for reusability for

WPF Interaction triggers in a Style to invoke commands on View Model [duplicate]

天大地大妈咪最大 提交于 2019-12-23 09:49:57
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How to add a Blend Behavior in a Style Setter when I use an interaction trigger in a style, I am getting the following error, 'triggers is not attachable element of type style'. Any explanation what this error actually means and how to solve it. For reference take a look at MVVM Light toolkit's EventToCommand example. In this particular case, I am using Timeline control from Infragistics which represents events

Can Execute of a ICommand while a Context menu open

我是研究僧i 提交于 2019-12-23 01:59:11
问题 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 it can hit while open the ContexMenu and it need to be hit(Checks) for each time while opening the ContextMenu . <Border> <Border.ContextMenu> <ContextMenu> <MenuItem Command="{Binding SaveCommand, Source={StaticResource vm}}" CommandParameter="{Binding}" Header="Menu1" /> </ContextMenu> <

Does MvvmCross work in Xamarin Studio?

Deadly 提交于 2019-12-21 17:48:49
问题 I'm having a time getting a straight answer on this, I've done a lot of searches and reading, and tried a lot of stuff. It sometimes sounds possible and other times only sounds possible by doing linking and what-not, which is something I'm trying to avoid. I'm a big fan of PCLs. I've created a solution using Visual Studio 2012, Xamarin, and MvvmCross which works great, I can deploy to an iOS device, a Droid device, Windows --- what have you. Visual Studio can build working applications that I

WPF: TreeViewItem bound to an ICommand

旧巷老猫 提交于 2019-12-18 13:19:37
问题 I am busy creating my first MVVM application in WPF. Basically the problem I am having is that I have a TreeView (System.Windows.Controls.TreeView) which I have placed on my WPF Window, I have decide that I will bind to a ReadOnlyCollection of CommandViewModel items, and these items consist of a DisplayString, Tag and a RelayCommand. Now in the XAML, I have my TreeView and I have successfully bound my ReadOnlyCollection to this. I can view this and everything looks fine in the UI. The issue

Relay Command can execute and a Task

岁酱吖の 提交于 2019-12-18 11:34:08
问题 i want to start a task when a relay command is called, however i want to disable the button as long as that task is running take this example private ICommand update; public ICommand Update { get { if (update == null) { update = new RelayCommand( param => Task.Factory.StartNew(()=> StartUpdate()), param => true); //true means the button will always be enabled } return update; } } what is the best way to check if that task is running? here is my solution but not sure if its the best way class

WPF ICommand vs RoutedCommand

自闭症网瘾萝莉.ら 提交于 2019-12-17 21:43:38
问题 Let's have a button Command property bound to a custom command. When should I implement ICommand and when derive from RoutedCommand ? I see that RoutedCommand implements ICommand . In which case could I need to iplement an ICommand ? What about MVVM model? Which one suits better for this purpose? 回答1: As you have noticed the RoutedCommand class is an implementation of the ICommand interface, its main distinction if that its function is similar to that of a RoutedEvent : The Execute and