어떻게 작동하는지 이해하려고하는 CM 규칙을 사용하고 있지만 어딘가에 단계별 설명이없는 품위있는 문서를 찾지 못했습니다. 어떻게 그리고 왜.Caliburn.Micro 여러 요소 사용자 지정 규칙 (NumericUpDown.Value, NumericUpDown.Maximum)
그러나 몇 가지 코드 스 니펫이 몇 가지 성공 사례를 통해 발견되었습니다. 그러나이 경우에는 무슨 일이 일어나고 있는지 이해할 수 없습니다.
NumericUpDown Value 및 Maximum을 해당 ViewModel 속성에 바인딩하려고합니다. 다음 코드와 함께 할 수 있었다 :
값
ConventionManager.AddElementConvention<NumericUpDown>(NumericUpDown.ValueProperty, "Value", "ValueChanged");
최대
ConventionManager.AddElementConvention<NumericUpDown>(NumericUpDown.MaximumProperty, "Maximum", "MaximumChanged");
var baseBindProperties = ViewModelBinder.BindProperties;
ViewModelBinder.BindProperties =
(frameWorkElements, viewModels) =>
{
foreach (var frameworkElement in frameWorkElements)
{
var propertyName = frameworkElement.Name + "Max";
var property = viewModels.GetPropertyCaseInsensitive(propertyName);
if (property != null)
{
var convention = ConventionManager.GetElementConvention(typeof(NumericUpDown));
ConventionManager.SetBindingWithoutBindingOverwrite(
viewModels,
propertyName,
property,
frameworkElement,
convention,
convention.GetBindableProperty(frameworkElement));
}
}
return baseBindProperties(frameWorkElements, viewModels);
};
그러나, 여기가 이상한 부분, 나는 단지 그들 중 하나가 작동 할 수 온다. 그게 내가 어딘가에서 멍청한 실수를하고 있다고 믿게한다. 거의 AddElementConvention 만 호출 할 수 있으므로 마지막 호출 만 실행됩니다.
이 코드 조각에 대한 도움이나 나를 도와 줄 수있는 좋은 설명서에 대한 참조를 보내 주시면 감사하겠습니다.
안부
나에게도 일어났습니다 : 불투명도, 활성화 등을 격자에 바인딩하고 싶었습니다. convention.GetBindableProperty (frameworkElement) 디버깅 중에 "Visibility"속성이 하나만 나타납니다. –