0
MVVM 라이트를 사용하여 코드를 수정합니다. 내 오래된 코드는 다음과 같습니다.MVVM에서 명령을 사용하여 그리드에서 RoutedEvent를 처리하는 방법 light wpf
<Grid x:Name="root" ButtonBase.Click="LayoutRoot_Click">
LayoutRoot_Click은 하위 컨트롤의 모든 RoutedEvent를 처리합니다. 그리드 this-
public class SomeViewModel : ViewModelBase
{
public SomeViewModel()
{
InputCommand = new RelayCommand(InputCode);
}
public ICommand InputCommand { get; set; }
private void InputCode()
{
string input = string.Empty;
}
}
처럼 뷰 모델이
<Grid x:Name="root" ButtonBase.Click="LayoutRoot_Click">
<i:Interaction.Triggers>
<i:EventTrigger EventName="ButtonBase.Click">
<mvvm:EventToCommand Command="{Binding InputCommand}" CommandParameter="{Binding ElementName=button1}" />
</i:EventTrigger>
</i:Interaction.Triggers>
같은 어떤 명령 인터페이스, 그래서 새로운 코드가없는 그러나이 작동하지 않기 때문에. 명령이 RoutedEvent를 얻지 못했습니다.