Caliburn.Micro를 사용할 때 ViewModel의 폼에서 명명 된 컨트롤을 찾는 좋은 방법이 있습니까? IoC는 양식에 접근 할 수있는 방법을 제공합니까?caliburn.micro를 사용할 때 양식에서 컨트롤을 찾는 가장 좋은 방법은 무엇입니까?
1
A
답변
5
당신은 버튼 컨트롤에 대한 예 Caliburn.Micro가보기를 전달합니다 (Screen
유형의 일부), 뷰 모델 AttachView
또는 OnViewLoaded
을 재정의 할 수
public override void AttachView(object view, object context)
{
base.AttachView(view, context);
var frameworkElement = view as FrameworkElement;
if (frameworkElement == null)
{
return;
}
var button = frameworkElement.FindName("myButton") as Button;
if (button == null)
{
return;
}
// access button control here
}
0
당신의 getView()를 호출 뷰 모델로부터도. 그런 다음 컨트롤을 검색하거나 이름으로 액세스하십시오.