问题
I've been trawling the MSDN for hours now and can't find an example of how to show or hide a CheckBox within a list in Windows Phone 8. An example would be within the messaging application, where the user uses the Application Bar to press a 'multiple selection' button. This allows the user to select multiple messages.
I've came across some information about using Expression Blend and the VisualStateManager
but for some reason it does not seem to be capable of applying state groups to a LongListSelector
.
All I want to do is create a list exactly like one within the messaging application of Windows Phone 8? Any help would be much appreciated.
My XAML code thus far:
<phone:LongListSelector x:Name="albumList" SelectionChanged="OnSelectionChanged" ItemsSource="{Binding Items}" >
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid Margin="0, 12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image x:Name="albumArt" Grid.Column="0" Width="96" Height="96" Source="{Binding CoverAddress}" Stretch="Uniform" Margin="12,0,0,0 " />
<StackPanel Grid.Column="1" Margin="0,0,0,17" VerticalAlignment="Center" >
<TextBlock Text="{Binding AlbumTitle}" TextWrapping="Wrap" Margin="12,0,0,0" FontSize="24"/>
<TextBlock Text="{Binding ArtistName}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
<CheckBox Grid.Column="2" />
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
Above are screenshots of the messaging application within Windows Phone 8. They show the change from a list to a multi-select list after having pressed a button within the Application Bar.
回答1:
It sounds like you want to use the MultiSelectList
from the Windows Phone toolkit, which can recreate the effect that you're looking for.
Information on how to use it is available from this blog post, or from the Samples that are included with the source code of the toolkit.
回答2:
all you need to do is set EnforceIsSelectionEnabled as true or false to show or hide the checkboxes using LongListMultiSelector
来源:https://stackoverflow.com/questions/15685504/how-to-show-hide-with-animation-if-possible-a-checkbox-within-a-longlistselect