gpt4 book ai didi

windows-phone-7 - SelectionChanged 事件发生在 SelectedItem 绑定(bind)之前

转载 作者:行者123 更新时间:2023-12-03 10:49:23 25 4
gpt4 key购买 nike

检查以下 XAML

<toolkit:ListPicker x:Name="MyListPicker" SelectionMode="Single" SelectedItem="{Binding sign,Mode=TwoWay}" Background="Wheat" ItemsSource="{Binding DataContext.Signs, ElementName=xx}" Width="40" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Grid.ColumnSpan="1">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmd:EventToCommand CommandParameter="{Binding SelectedItem,ElementName=MyListPicker}" Command="{Binding DataContext.generate, ElementName=xx}"/>
</i:EventTrigger>
</i:Interaction.Triggers>

当我更改此 ListPicker 的选择时,此事件调用将调用生成方法的生成命令,其中我将使用已通过 CommandParameter 传递给我的 View 模型的 SelectedItem,我的方法上 SelectedItem 的值仍然存在同样,当我再次执行此操作时,它会更改为上一个值而不是最近选择的值,在我看来,与 SelectedItem 的绑定(bind)发生在执行 SelectionChanged 之后,该方法使用上一个值执行,任何想法/解决方法?

最佳答案

也许一个可能的解决方法是使用“SelectedIndex”而不是“SelectedItem”,然后尝试通过这个索引从列表中获取元素......它有效。你得到正确的索引,什么时候改变。

关于windows-phone-7 - SelectionChanged 事件发生在 SelectedItem 绑定(bind)之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10861220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com