您好我正在尝试使用EventToCommand我使用了棱镜库,但我遇到的问题很少,如下所述。
MyTestSwitch_1可以正常执行ToggledCommand,但是当我尝试点击基于listview项生成的MyTestSwitch_ListView时,它没有做任何事情都不会给任何异常应用程序不崩溃它只是忽略EventToCommand行为
有谁知道可能出错了什么。谢谢。
<StackLayout>
<Switch x:Name="MyTestSwitch_1" IsToggled="{Binding ValueB}}">
<Switch.Behaviors >
<b:EventToCommandBehavior EventName="Toggled"
Command="{Binding ToggledCommand}"/>
</Switch.Behaviors>
</Switch>
<ListView x:Name="MyListView"
ItemsSource="{Binding ValuesList}"
ItemTapped="Handle_ItemTapped"
CachingStrategy="RecycleElement"
HasUnevenRows="True"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding RefreshCommand}"
IsRefreshing="{Binding IsRefreshing, Mode=OneWay}"
Margin="10">
<ListView.Behaviors>
<b:EventToCommandBehavior EventName="ItemTapped"
Command="{Binding ItemTappedCommand}"
CommandParameter="MyParameter" />
</ListView.Behaviors>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding Id}"
Style="{DynamicResource ListItemTextStyle}" />
<Label Text="{Binding Value}"
Style="{DynamicResource ListItemDetailTextStyle}"/>
<Switch x:Name="MyTestSwitch_ListView" IsToggled="{Binding ValueB}}">
<Switch.Behaviors >
<b:EventToCommandBehavior EventName="Toggled"
Command="{Binding ToggledCommand}, Source={x:Reference ThisPage}"
CommandParameter="{Binding .}" />
</Switch.Behaviors>
</Switch>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
答案 0 :(得分:-1)