LongListSelector with list item selection style

后端 未结 1 612
闹比i
闹比i 2021-01-26 10:23

I am working on Windows Phone 8 and i have Longlist selector with few item in it.

I am using the below code for highlighting the selected item in the list box.But i want

相关标签:
1条回答
  • 2021-01-26 11:25

    I try your code, but the LongListSelector control display a list of selectable items with a mechanism for users to jump to a specific section of the list. This is the sample code.

    But if you want achieved the effect like ListBox, you can set the template

    <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="phone:LongListSelector">
                            <Grid Background="{TemplateBinding Background}" d:DesignWidth="480" d:DesignHeight="800">
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="ScrollStates">
                                        <VisualStateGroup.Transitions>
                                            <VisualTransition GeneratedDuration="00:00:00.5"/>
                                        </VisualStateGroup.Transitions>
                                        <VisualState x:Name="Scrolling">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="VerticalScrollBar"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="NotScrolling"/>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal"/>
                                        <VisualState x:Name="Seleced">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ViewportControl">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Green"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Grid Margin="{TemplateBinding Padding}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="auto"/>
                                    </Grid.ColumnDefinitions>
                                    <ViewportControl x:Name="ViewportControl" HorizontalContentAlignment="Stretch" VerticalAlignment="Top"/>
                                    <ScrollBar x:Name="VerticalScrollBar" Grid.Column="1" Margin="4,0,4,0" Opacity="0" Orientation="Vertical"/>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
    
    0 讨论(0)
提交回复
热议问题