So, I am fairly new to Silverlight development and I am trying to figure out and use the Caliburn.Micro framework. I understand that CM is using convention to match properties in the view model with elements in the view and that the default conventions can be found in the ConventionManager Class of CM.
My situation is this: I have a TreeView (using the Silverlight Toolkit) named "Libraries" and I have successfully bound a property of type ObservableCollection in my view model to the TreeView. The property is also named "Libraries" so CM did the rest.
Now, I want to create a property in the view model that will be set with the TreeView's SelectedItem. How should I do this using CM's conventions? What should I name the property?
And finally, I want a method in the view model to be called when the TreeView's SelectedItemChanged event is fired. What should I name the method so that this is accomplished via convention?
Can anyone help with this?
Eisenberg...Eisenberg...(in my best Ben Stein impersonation)
Thanks, David
EDIT: I should also note that I have modified the CM assembly to add the following line to the ConventionsManager's constructor as it was previously excluded from the Silverlight version of CM dll:
开发者_JAVA百科AddElementConvention(TreeView.ItemsSourceProperty, "SelectedItem", "SelectedItemChanged");
You should be able to create a public property named SelectedLibrary or ActiveLibrary and CM will do the rest. If that doesn't work you can always fall back on an Action:
cal:Message.Attach="[Event SelectedItemChanged] = [Action SelectedLibrary($eventArgs)]"
edit: do you need a property setter and a method to fire?
精彩评论