wpf-commands

WPF Commands - changing target control's property

I am creating a command which will have a Textbox control as target. Code to create the command: public class Commands { public static RoutedCommand Appender; static Commands() { Appender = new RoutedCommand(); } public static void AppenderExecuted(object target, ExecutedRoutedEventArgs e) { Sy...

Let parent handle the child controls event or command WPF?

Hi, I have a user control that has 2 controls A and B within it. Now, A and B have their own logic in their DragDrop event. The parent that has these 2 controls has to handle the DragDrop from these events in its own way. So I have in the parent something like, parent.A.DragDropEvent += new EventHandler () etc... Now, I want to handl...

MVVM Light - CanExecute method on RelayCommand instance always executing

Hi, I tried with a minimal application, just a textbox and a button. The button is binded to a RelayCommand instance, and the CanExecute method just return true or false with a random. The textbox text is binded with a string property. What's making me mad is that the CanExecute method is "always" called: a change of the element focus...

How can I databind a non-command MenuItem IsEnabled to stay consistent with a command based MenuItem?

This menuItem because it's linked to a command does the magic behind the scenes for me: <MenuItem Name="mnuOpen" Command="Open"/> where I have <Window.CommandBindings> <CommandBinding Command="Open" Executed="CommandBinding_Open_Executed" CanExecute="CommandBinding_ProjectSelected"/>...

Execute a usercontrol command from a viewmodel

I have a usercontrol with a command, what I would like to do is execute this command from the containing view's ViewModel. This would be easy to accomplish in the code behind, as I could just go "UserControl.MyCommand.Execute", but of course I want to be able to do this in the ViewModel. In theory, what I would like to do is bind the U...

WPF command - called from Window and UserControl, same handlers

How can I have a Command that can be called from both a Window and a UserControl (by hitting a button in either) that uses the same execute and can-execute methods? It seems like if I have the following in my UserControl's XAML, it requires myCommandHandler and canExecuteMyCommand to be in my UserControl class: <CommandBinding Command=...

Why is one of my ScrollViewer commands not working in ListBox template?

Got a weird problem here. I have created a template for a ListBox based on the standard template (i.e. I have not changed anything other than what I indicate below). I am trying to add a couple of buttons to the side of the template so that I can scroll the ScrollViewer (which is part of the standard ListBox template) left and right. Th...

Prism: Prevent executing a command in duplicate views using IActiveAware?

Hi There, I have a Silverlight application that has three regions that will host the same Views. What I want to know is, how may I create a zoom control for each of the views, without zooming all of the views (assuming the zoom action is using Prism Commands). Would IActiveAware be the right approach? ...