0

リストボックスの項目をグループ化しました。SelectionMode="Extended" または "Multiple" で "Multiple" 項目を選択できます。今、私は「ソート」で2つの問題ともう1つの問題を抱えています

  1. いつ

[SelectionMode="拡張"]

マウスを使用してアイテムを押して選択することで、複数のアイテムを選択できます。マウスを他のコントロールに移動すると、選択が失われます。

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