Xaml 将Xuni日历选择更改事件绑定到ViewModel(带Prism的Xamarin表单)

Xaml 将Xuni日历选择更改事件绑定到ViewModel(带Prism的Xamarin表单),xaml,xamarin,mvvm,xamarin.forms,prism,Xaml,Xamarin,Mvvm,Xamarin.forms,Prism,我想在我的Xamarin Forms应用程序Prism中使用。 如何使用将日历控件的SelectionChanged事件绑定到ViewModel中的命令,因为我不想使用代码隐藏。 到目前为止,这是我的XAML <xuni:XuniCalendar x:Name="calendar" MaxSelectionCount="-1" Grid.Row="0" Grid.ColumnSpan="2"> <xuni:XuniCalendar.Behaviors>

我想在我的Xamarin Forms应用程序Prism中使用。 如何使用将日历控件的SelectionChanged事件绑定到ViewModel中的命令,因为我不想使用代码隐藏。 到目前为止,这是我的XAML

<xuni:XuniCalendar x:Name="calendar" MaxSelectionCount="-1" Grid.Row="0" Grid.ColumnSpan="2">
    <xuni:XuniCalendar.Behaviors>
        <b:EventToCommandBehavior EventName="SelectionChanging" Command="{Binding SelectionChangingCommand}"
                              EventArgsConverter="{StaticResource selectionChangingEventArgsConverter}" />
    </xuni:XuniCalendar.Behaviors>
</xuni:XuniCalendar> 
下面是我的ViewModel中的命令:

public DelegateCommand SelectionChangingCommand => new DelegateCommand(SelectionChanging);

private void SelectionChanging()
{
    throw new NotImplementedException();
}
我没有收到任何错误,但ViewModel中的SelectionChanging命令未被触发

谢谢,
Uwe

实际上不需要创建转换器,只需指定命令、事件名称和EventArgs路径SelectedDates

在ViewModel中,需要使用通用的DelegateCommand来接受参数。根据所选日期,有一个列表,因此在ViewModel中需要以下内容

public DelegateCommand<List<DateTime>> SelectionChangingCommand { get; }

public void OnSelectionChangingCommandExecuted(List<DateTime> selectedDates)
{
    // Do stuff
}

这很有效。谢谢我只需要用EventArgsParameterPath替换Path就可以运行它。
<xuni:XuniCalendar MaxSelectionCount="-1" 
                   Grid.Row="0" 
                   Grid.ColumnSpan="2">
    <xuni:XuniCalendar.Behaviors>
        <b:EventToCommandBehavior EventName="SelectionChanging" 
                                  Command="{Binding SelectionChangingCommand}"
                                  Path="SelectedDates" />
    </xuni:XuniCalendar.Behaviors>
</xuni:XuniCalendar> 
public DelegateCommand<List<DateTime>> SelectionChangingCommand { get; }

public void OnSelectionChangingCommandExecuted(List<DateTime> selectedDates)
{
    // Do stuff
}