0
votes

I have the following XAML:

<phone:LongListSelector.ItemTemplate>
<DataTemplate>
    <StackPanel Margin="0,0,0,17" >
        <TextBlock Text="{Binding Path=Name, Mode=TwoWay}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" />
        <TextBlock Text="{Binding Path=State.Summary, Mode=TwoWay}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
        <toolkit:ToggleSwitch x:Name="stateToggle" x:Uid="{Binding Path=Id, Mode=TwoWay}" IsChecked="{Binding Path=State.Current, Mode=TwoWay}" Click="stateToggle_Click_1" ></toolkit:ToggleSwitch>
    </StackPanel>
</DataTemplate> 
</phone:LongListSelector.ItemTemplate>

I am trying to achieve the following: 1) Take an action on toggle switch click (handle an event) 2) Take an action when an item from the list is tapped i.e. outside the borders of the toggle switch.

I have tried SelectionChanged and ToggleSwitch Click but that way I still invoke both events when the toggle switch is clicked.

Any ideas?

1

1 Answers

0
votes

If SelectionChanged works for use case 2, then you are basically there.

You should set the MouseEventArgs Handled property to true in your ToggleSwitch Click handler. That way the selection should not be changed (because the listitem has not been clicked) and only the click event you want should be raised.