Caliburn.Micro right now (1.3.1) doesn't really support this "multiple" conventions for the same FrameworkElement
, what you have described.
EDIT:
However you can hook into the ViewModelBinder.BindProperties
method and there you can implement your own extra convetion.
I went one step further and implemented a prototype which works, but it's not robust, nor elegant and probably not the correct way to do this. But it can be a starting point:
static AppBootstrapper()
{
ConventionManager.AddElementConvention<FrameworkElement>(
UIElement.IsEnabledProperty,
"IsEnabled",
"IsEnabledChanged");
var baseBindProperties = ViewModelBinder.BindProperties;
ViewModelBinder.BindProperties =
(frameWorkElements, viewModels) =>
{
foreach (var frameworkElement in frameWorkElements)
{
var propertyName = frameworkElement.Name + "Enabled";
var property = viewModels
.GetPropertyCaseInsensitive(propertyName);
if (property != null)
{
var convention = ConventionManager
.GetElementConvention(typeof(FrameworkElement));
ConventionManager.SetBindingWithoutBindingOverwrite(
viewModels,
propertyName,
property,
frameworkElement,
convention,
convention.GetBindableProperty(frameworkElement));
}
}
return baseBindProperties(frameWorkElements, viewModels);
};
}
IsEnabled
andIsReadOnly
is pretty common in a UI. [I assumed my GoogleFu was at fault when I couldn't find an answer myself.] – Alexandros