1
XAML 측에서 이벤트를 명령에 바인딩하기 위해 아래 솔루션을 얻었으며 은 매우 양호합니다..WPFS 이벤트를 MVVM ViewModel 명령에보기 뒤에 코드로 묶습니다.
참조
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
버튼 정의 :는
<Button>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter" >
<i:InvokeCommandAction Command="{Binding FooCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
문제 : 지금 내 개체에 대한 뒤에 코드에서 같은 일을 할 필요가 인 FrameworkElementFactory 그러나 나는 그것을 알아낼 수 없다, 나는 아마 하나가 나를 도울 수 있다고 생각했다.
FrameworkElementFactory newLabel = new FrameworkElementFactory(typeof(Label));
newLabel.SetValue(Label.BackgroundProperty, Brushes.DarkMagenta);
var eventTrigger = new System.Windows.Interactivity.EventTrigger("MouseDown");
var invokeCommandAction = new System.Windows.Interactivity.InvokeCommandAction()
{
CommandName = "FooCommand",
CommandParameter = new Object()
};
도움하십시오 : 나는 중지 된 위치 여기
은? 사전에
감사합니다, 자드