0

我已经对列表框项目进行了分组,我可以通过 SelectionMode="Extended" 或 "Multiple" 选择 "Multiple" 项目。现在我在“排序”中有两个问题和一件事

  1. 什么时候

[选择模式=“扩展”]

我可以通过按下并使用鼠标选择项目来选择多个项目,一旦我将鼠标移动到其他控件,我就会失去我的选择。

2.我无法使用键盘选择多个项目,也无法使用箭头键前往 listboxItems(即)“图像”。

  1. 我想对分组的项目进行排序/排列。任何人都可以提前指导这些..thnx。

        <CollectionViewSource x:Key="CharacterCollectionView" 
        Source="{Binding}" >
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Name" />
             </CollectionViewSource.GroupDescriptions>
            <!--<CollectionViewSource.SortDescriptions>
                <cm:SortDescription PropertyName="First" />
            </CollectionViewSource.SortDescriptions>-->
        </CollectionViewSource>
    
        <ItemsPanelTemplate x:Key="HorizontalItemsPanel">
            <WrapPanel  Orientation="Horizontal" HorizontalAlignment="Stretch" />
        </ItemsPanelTemplate>
    
               <Style x:Key="myListboxStyle">
            <Style.Resources>
                <!-- Background of selected item when focussed -->
                <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#66000000" Offset="0" />
                    <GradientStop Color="#33000000" Offset="1" />
                </LinearGradientBrush>
                <!-- Background of selected item when not focussed -->
                <LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#66000000" Offset="0" />
                    <GradientStop Color="#33000000" Offset="1" />
                </LinearGradientBrush>
            </Style.Resources>
        </Style>
    
    
    </Window.Resources>
    
        <DockPanel>
        <StackPanel Orientation="Vertical" DockPanel.Dock="Left" Background="#336699" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
        <ListBox
            Margin="20,20,20,5" DataContext="{Binding}"
            ItemsSource="{Binding Source={StaticResource CharacterCollectionView}}" 
            DockPanel.Dock="Top" x:Name="MyList" MouseEnter="MyListEvent"
            Width="700" SelectionMode="Extended"    Style="{StaticResource myListboxStyle }"
            Height="700" Background="LightGray" IsSynchronizedWithCurrentItem="True" 
            ScrollViewer.CanContentScroll="True" SelectedIndex="1"
            ScrollViewer.VerticalScrollBarVisibility="Visible" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"   
            ScrollViewer.HorizontalScrollBarVisibility="Disabled" PresentationTraceSources.TraceLevel="High"  >
    
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                    <Setter Property="Padding" Value="0"/>
                    <Setter Property="Margin" Value="1"/>
                    <Setter Property="BorderBrush" Value="Green"/>
                    <Setter Property="Width" Value="{Binding Path=Value, ElementName=sizeSlider, Mode=TwoWay}"/>
                    <Setter Property="Height" Value="{Binding Path=Value, ElementName=sizeSlider, Mode=TwoWay}"/>
    
                                               <!--<Style.Triggers>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="IsSelected" Value="True" />
                        </Trigger>
                    </Style.Triggers>-->
    
                </Style>
            </ListBox.ItemContainerStyle>
    
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Background="LightSteelBlue"   />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
    
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Viewbox Stretch="Fill" HorizontalAlignment="Stretch" >
                        <Border BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding}" BorderBrush="IndianRed"   Margin="0" Height="Auto">
                            <DockPanel>
                                <Image
                                    DockPanel.Dock="Top"
                                    Width="150" Margin="5"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    Height="Auto"  x:Name="Myimage"
                                    Source="{Binding Path=ImageFilepath[0]}"/>
                                <Grid>
                                    <Label Content="{Binding Path=Name[0]}" HorizontalContentAlignment="Center" FontWeight="Normal"   FontSize="13"  />
                                </Grid>
                            </DockPanel>
                        </Border>
                    </Viewbox>
                </DataTemplate>
            </ListBox.ItemTemplate>
    
                     <ListBox.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" FontSize="18"  Height="Auto" Background="Transparent" FontWeight="Medium"  />
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Horizontal"     HorizontalAlignment="Stretch" Background="White"        />
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                        <GroupStyle.ContainerStyle>
    
                            <Style TargetType="{x:Type GroupItem}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type GroupItem}">
                                            <GroupBox Header="{Binding Name}" BorderBrush="#336699" BorderThickness="2" Margin="5">
                                                <ItemsPresenter />
                                           </GroupBox>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </GroupStyle.ContainerStyle>
                    </GroupStyle>
               </ListBox.GroupStyle>
    
            </ListBox>
        <StackPanel Grid.Row="1" HorizontalAlignment="Center" Orientation="Horizontal" Margin="2,0,5,5">
            <TextBlock Width="Auto" Text="Min" Foreground="White" FontWeight="Bold" FontSize="14"  Margin="2" Padding="0" HorizontalAlignment="Right"  />
            <Slider
            Name="sizeSlider"
            Width="300" Orientation="Horizontal"  
            Value="200" Background="PowderBlue"      
            IsSnapToTickEnabled="True"
            Minimum="150" Maximum="250"
            TickPlacement="BottomRight"
            TickFrequency="50"
            AutoToolTipPrecision="10"
            AutoToolTipPlacement="TopLeft"  
            IsDirectionReversed="False"   
            IsMoveToPointEnabled="False" />
    
                <TextBlock Width="Auto" Text="{Binding Value, ElementName=sizeSlider}" Foreground="White" FontWeight="Bold" FontSize="14"  Margin="2" Padding="0" />
        </StackPanel>
    
4

0 回答 0