commandbinding

When will the CanExcute event be raised by the CommandSource

Hi, When will the CanExecute event be ideally raised by the control that realizes the ICommandSource interface?? I tried to add a breakpoint to the handler to check when it is getting raised and it seems to be executed whenever the control is rendered on the screen. Can someone explain when exactly it will be raised and how to raise ...

MVVM - In a list of objects, each containing a command, how can I get the appropriate command to fire?

Maybe I'm going about this the wrong way but in my view model I have a list of objects (CGCAppSwitchboardItem) that each contain a DelegateCommand property. My intention here is that each item (CGCAppSwitchboardItem) in my list would represent a module inside my solution whereby a call to the command will load a module. Or, better said, ...

WPF Routed Command with Bindings per-Tab

I intended to disable and enable the Buttons outside the TabControl, just like those inside the TabItem when the current tab is changed. But the CommandBindings of the TabItem do not seem to impact "up" the visual tree. What is the right way to do this? With this XAML: <Window x:Class="WpfApplication10.MainWindow" xmlns="http://sch...

WPF: Trouble controlling a button's enabled/disabled state using Command binding and a thread

I have a WPF app that simply contains a Button and a Textbox to display some output. When the user clicks the Button, a thread starts which disables the Button, prints stuff to the output Textbox, then the thread stops (at which point I want the Button to be enabled again). The application appears to disable the Button properly, as wel...

How to fire a Command when a window is loaded in wpf

Is it possible to fire a command to notify the window is loaded. Also, I'm not using any MVVM frameworks (Frameworks in the sense, Caliburn, Onxy, MVVM Toolkit etc.,) ...

Issue adding ribbon buttons directly to quick access toolbar

I am trying to add a Ribbon Button directly to the Quick Access Toolbar by using the CanAddToQuickAccessToolBarDirectly property. I have read in order to do this a command must be enabled on the button from this source (http://blogs.msdn.com/b/llobo/archive/2010/08/06/wpf-ribbon-basics.aspx#comments). When I add a command to the button i...

CanExecute method going to false problem

Well, in our application this usually works fine. But at some point, none of the CanExecute methods fire (even if I explicitly call CommandManager.InvalidateRequerySuggested(), the CanExecute methods don't run). Anyway, despite the fact that they don't run, they all get set to false, so every button, menu item, etc, bound to a CommandBin...

How to make sender to be a Button and not the MainWindow in WPF CommandBinding ?

The Button in WPF MainWindow has normal command attribute. When clicked the handler method receives sender. But the sender is always MainWidow. How to get sender to be a Button ? I need it to be a particular button, because I set this command to several buttons and want to use single handler for many senders. Thank you ...

How to use the text of a routed command as button content

I have a button on a view that is bound via a RoutedUICommand to a command defined in the ViewModel. The XAML code excerpt from the view: <Button Content="Login" Command="{Binding Login}" /> In the View's CodeBehind I add the command binding from the ViewModel to the view's binding collection: this.CommandBindings.Add( viewModel.Lo...

CommandBinding question. How to enable command button

My code is here>> public class Player:INotifyPropertyChanging { string addressBar; public string Url { get { return addressBar; } set { addressBar = value; OnPropertyChanged("Url"); } } public Regex regVillage = new Regex(@"\?doc=\d+&sys=[a-zA-Z...

WPF DataGrid: CommandBinding to a double click instead of using Events

I know how to use the MouseDoubleClick event with my DataGrid to grab the selectedvalue, but how would one go about using command bindings instead? That way my ViewModel can handle the logic. So far I have the following: <DataGrid Name="TestGrid" Grid.Row="2" Grid.ColumnSpan="2" AutoGenerateColumns="True" MouseDoubleClick="TestGrid_Mou...

How to force a RibbonButton to be alway enabled ?

I have a Microsoft Ribbonbar inside a Window, and every RibbonButton is associated to a specific command like this: <ribbon:Ribbon x:Key="MyToolbar" Name="MyToolbar" > <ribbon:RibbonTab Header="File" > <ribbon:RibbonGroup Header="File" > <ribbon:RibbonButton Command="{x:Static ApplicationCommands.New}" LargeImageSource="Ima...

Command Binding not working when the host control is added programatically in wpf

This is weird. I have a UserControl (MyControl) with a button inside. I have added a command to this button whose command target is another user control which is again added to the same window. When I add the UserControl statically in xaml to the CustomControl's host space, the CommandBinding system works fine, where as the same doesn't...