I have a ListBox with RadioButton inside it of the same GroupName.
Like so:
<ListBox x:Name="AnswerListBox" DataContext="{Binding .}" ItemsSource="{Binding Answers}" Width="auto" HorizontalAlignment="Center" >
<ListBox.ItemTemplate>
<DataTemplate>
<local:spriteToggleButton DataContext="{Binding .}" HorizontalAlignment="Center" Text="{Binding text}" Selected="{开发者_如何学JAVABinding selected}" Sprites="{Binding Path=DataContext.UISprites, ElementName=questionField}" IsChecked="{Binding selected, Mode=TwoWay}" GroupName="{Binding Path=DataContext.QuestionTitle, ElementName=questionField}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
When I click on a RadioButton it will unselect another in that group, this is fine.
But when I do a swipe down on the ListBox it will select more than one RadioButton which is an unwanted behavior.
There might be more than one way of changing that behavior.
I don't need it to scroll up and down the list as I will only show as many items as will fit on screen. so maybe that behavior can be disabled.
Maybe a callback could incur when the ListBox is scrolled and something could disable selection when dragging in being done.
the DataContext to the listbox is of List<> so is there a way to change the setter of my Selected variable in my List<> so that it unsets the other values in that list.
Set
ScrollViewer.VerticalScrollBarVisibility
to "Disabled" on theListBox
element.In the
SelectionChanged
event, set theSelectedIndex
to -1You could clear all the other values in the
ItemsSource
in theSelectionChanged
event.
精彩评论