1
votes

check the following 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>

when I change the selection of this ListPicker, this event invoke the generate command which will call Generate Method, in which I will be using the SelectedItem which I've already passed to my viewmodel via the CommandParameter, the value of SelectedItem on my method remains the same, when I do it again , it changes to the previous value not the one most recently selected , it seems to me that the binding to the SelectedItem occur after the SelectionChanged executed, the method executes with the previous value , any ideas/workarounds ?

1

1 Answers

0
votes

Maybe a possible workaround is using "SelectedIndex" instead "SelectedItem" then try get the element from list by this index...it Works. You get the right Index, when is changed.