I am using Caliburn.Micro (2.0.2, currently the latest version) with a WPF application. Say I have a simple list of items, and I want to include some actions for the selected item. The action is tied to a button.
So my VM provides a bindable collection of these elements (e.g. Persons) and an object of the same type associated with the selected element (e.g. SelectedPerson). Say the action corresponds to a method with a name Test, and I have a guard property CanTestthat returns true when the selected item is not null. When SelectedPersonchanging, I also call NotifyOfPropertyChangedfor CanTest.
This trivial scenario works fine: when nothing is selected, the button corresponding to my action is disabled; when i select any item it turns on.
The problem arises when I bind a method to a control event using Message.Attach: say, I want to attach it to a double click. My XAML will look like this:
<ListBox ItemsSource="{Binding Path=Persons,Mode=OneWay}"
SelectedItem="{Binding Path=SelectedPerson,Mode=TwoWay}"
cal:Message.Attach="[Event MouseDoubleClick] = [Action Test]"/>
This completely disables the control (the entire control, not just the child button, so I can never select an item in the ListBox that is permanently disabled). The only way to enable it is to remove the guard property from my virtual machine (or Message.Attachfrom the view).
You can find simple reprograms at http://1drv.ms/1OTSgq2 .
https://caliburnmicro.codeplex.com/discussions/246571, , -, , , , , IsEnabled guard. , .