none
wp8.1RT LongListMultiSelector 有什么控件可以代码吗 RRS feed

答案

  • 你好,

    >>比如短信界面 前面的蓝色区域,8.0toolkit的LongListMultiSelector 默认是支持点击的。 8.1的listview好像点击不了

    我们可以自定义ListView的数据模板DataTemplate, 在前面位置添加一个Button控件,这样就可以点击了:

    <DataTemplate x:Key="GroupTemplate">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="15" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border>
                            <Button Width="15" Style="{StaticResource MyButtonStyle}" Click="Button_Click" />
                        </Border>
                        <StackPanel Grid.Column="1" Margin="14.5,0,0,0">
                            <TextBlock Text="{Binding Time}"
                                       Style="{ThemeResource ListViewItemTextBlockStyle}" />
                            <TextBlock Text="{Binding Event}"
                                       Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>

    对于Button应用了自定义模板(参考此MSDN文档:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709909.aspx)

    <SolidColorBrush x:Key="ButtonBackgroundThemeBrush" Color="#B3B6B6B6" />
                <SolidColorBrush x:Key="ButtonBorderThemeBrush" Color="#33000000" />
                <SolidColorBrush x:Key="ButtonDisabledBackgroundThemeBrush" Color="#66CACACA" />
                <SolidColorBrush x:Key="ButtonDisabledBorderThemeBrush" Color="#1A000000" />
                <SolidColorBrush x:Key="ButtonDisabledForegroundThemeBrush" Color="#66000000" />
                <SolidColorBrush x:Key="ButtonForegroundThemeBrush" Color="#FF000000" />
                <SolidColorBrush x:Key="ButtonPointerOverBackgroundThemeBrush" Color="#D1CDCDCD" />
                <SolidColorBrush x:Key="ButtonPointerOverForegroundThemeBrush" Color="#FF000000" />
                <SolidColorBrush x:Key="ButtonPressedBackgroundThemeBrush" Color="#FF000000" />
                <SolidColorBrush x:Key="ButtonPressedForegroundThemeBrush" Color="#FFFFFFFF" />
                <FontFamily x:Key="ContentControlThemeFontFamily">Segoe UI</FontFamily>
                <x:Double x:Key="ControlContentThemeFontSize">14.667</x:Double>
                <SolidColorBrush x:Key="FocusVisualBlackStrokeThemeBrush" Color="Black" />
                <SolidColorBrush x:Key="FocusVisualWhiteStrokeThemeBrush" Color="White" />
                <Style TargetType="Button" x:Name="MyButtonStyle">
                    <Setter Property="Background" Value="{ThemeResource ButtonBackgroundThemeBrush}" />
                    <Setter Property="Foreground" Value="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderThemeBrush}" />
                    <Setter Property="BorderThickness" Value="0" />
                    <Setter Property="Padding" Value="12,4,12,4" />
                    <Setter Property="HorizontalAlignment" Value="Left" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Button">
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPointerOverBackgroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPointerOverForegroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPressedBackgroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPressedForegroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledBackgroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledBorderThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledForegroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                        <VisualStateGroup x:Name="FocusStates">
                                            <VisualState x:Name="Focused">
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                                    <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Unfocused" />
                                            <VisualState x:Name="PointerFocused" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Margin="3">
                                        <ContentPresenter x:Name="ContentPresenter"
                                              Content="{TemplateBinding Content}"
                                              ContentTransitions="{TemplateBinding ContentTransitions}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                              AutomationProperties.AccessibilityView="Raw"/>
                                    </Border>
                                    <Rectangle x:Name="FocusVisualWhite"
                                   IsHitTestVisible="False"
                                   Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="1.5" />
                                    <Rectangle x:Name="FocusVisualBlack"
                                   IsHitTestVisible="False"
                                   Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="0.5" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

    应用模板:

    <ListView
                ItemTemplate="{StaticResource GroupTemplate}"
                ItemsSource="{Binding}" />

    截图:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年11月14日 5:13
    版主

全部回复

  • 一般建議是 ListView

    如何添加列表视图 (XAML)

    ListView Class


    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    2014年11月13日 15:10
  • 你好 ,

    测试发现 listview可以通过设置SelectionMode = ListViewSelectionMode.Multiple打开复选框,

    可是如何让他支持点击文本前空白区域就打开复选框?

    2014年11月13日 16:13
  • 可以貼張圖描述一下你所指的空白區域嗎 ?

    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    2014年11月13日 16:42
  • 比如短信界面 前面的蓝色区域,8.0toolkit的LongListMultiSelector 默认是支持点击的。

    8.1的listview好像点击不了

    2014年11月14日 2:17
  • 你好,

    >>比如短信界面 前面的蓝色区域,8.0toolkit的LongListMultiSelector 默认是支持点击的。 8.1的listview好像点击不了

    我们可以自定义ListView的数据模板DataTemplate, 在前面位置添加一个Button控件,这样就可以点击了:

    <DataTemplate x:Key="GroupTemplate">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="15" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border>
                            <Button Width="15" Style="{StaticResource MyButtonStyle}" Click="Button_Click" />
                        </Border>
                        <StackPanel Grid.Column="1" Margin="14.5,0,0,0">
                            <TextBlock Text="{Binding Time}"
                                       Style="{ThemeResource ListViewItemTextBlockStyle}" />
                            <TextBlock Text="{Binding Event}"
                                       Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>

    对于Button应用了自定义模板(参考此MSDN文档:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709909.aspx)

    <SolidColorBrush x:Key="ButtonBackgroundThemeBrush" Color="#B3B6B6B6" />
                <SolidColorBrush x:Key="ButtonBorderThemeBrush" Color="#33000000" />
                <SolidColorBrush x:Key="ButtonDisabledBackgroundThemeBrush" Color="#66CACACA" />
                <SolidColorBrush x:Key="ButtonDisabledBorderThemeBrush" Color="#1A000000" />
                <SolidColorBrush x:Key="ButtonDisabledForegroundThemeBrush" Color="#66000000" />
                <SolidColorBrush x:Key="ButtonForegroundThemeBrush" Color="#FF000000" />
                <SolidColorBrush x:Key="ButtonPointerOverBackgroundThemeBrush" Color="#D1CDCDCD" />
                <SolidColorBrush x:Key="ButtonPointerOverForegroundThemeBrush" Color="#FF000000" />
                <SolidColorBrush x:Key="ButtonPressedBackgroundThemeBrush" Color="#FF000000" />
                <SolidColorBrush x:Key="ButtonPressedForegroundThemeBrush" Color="#FFFFFFFF" />
                <FontFamily x:Key="ContentControlThemeFontFamily">Segoe UI</FontFamily>
                <x:Double x:Key="ControlContentThemeFontSize">14.667</x:Double>
                <SolidColorBrush x:Key="FocusVisualBlackStrokeThemeBrush" Color="Black" />
                <SolidColorBrush x:Key="FocusVisualWhiteStrokeThemeBrush" Color="White" />
                <Style TargetType="Button" x:Name="MyButtonStyle">
                    <Setter Property="Background" Value="{ThemeResource ButtonBackgroundThemeBrush}" />
                    <Setter Property="Foreground" Value="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderThemeBrush}" />
                    <Setter Property="BorderThickness" Value="0" />
                    <Setter Property="Padding" Value="12,4,12,4" />
                    <Setter Property="HorizontalAlignment" Value="Left" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Button">
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPointerOverBackgroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPointerOverForegroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPressedBackgroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPressedForegroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="Background">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledBackgroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledBorderThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledForegroundThemeBrush}" />
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                        <VisualStateGroup x:Name="FocusStates">
                                            <VisualState x:Name="Focused">
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                                    <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Unfocused" />
                                            <VisualState x:Name="PointerFocused" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Margin="3">
                                        <ContentPresenter x:Name="ContentPresenter"
                                              Content="{TemplateBinding Content}"
                                              ContentTransitions="{TemplateBinding ContentTransitions}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                              AutomationProperties.AccessibilityView="Raw"/>
                                    </Border>
                                    <Rectangle x:Name="FocusVisualWhite"
                                   IsHitTestVisible="False"
                                   Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="1.5" />
                                    <Rectangle x:Name="FocusVisualBlack"
                                   IsHitTestVisible="False"
                                   Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="0.5" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

    应用模板:

    <ListView
                ItemTemplate="{StaticResource GroupTemplate}"
                ItemsSource="{Binding}" />

    截图:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年11月14日 5:13
    版主