Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Windows Presentation Foundation
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Windows Presentation Foundation Discussion of the beta version of Windows Presentation Foundation "WPF" formerly know as codename "Avalon" as well as the related XAML.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Windows Presentation Foundation section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 28th, 2013, 02:34 AM
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2010
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default wpf Select Multiple ListboxItems(i.e, Images) using Keyboard[Ctrl + RightArrow/leftAr

I Have grouped the listbox items,i can able to select "Multiple" items by SelectionMode="Extended" or "Multiple". Now i have got two issues and one more thing in "Sorting"

[ SelectionMode="Extended"]

i can select Multiple Items by pressing and selecting the items using Mouse, once i move the mouse to the others controls,i'm losing my selection.

2.I'm unable to select Multiple items using Keyboard and unable to travel to listboxItems(i.e,) "Images" using Arrow Keys.

3.I want to sort/Arrange the grouped Items. could anybody guide over these..thnx in advance.

In code behind i have handled KeyUp for ListBox so that the travelling to the listbox items are Not happening, if i don't handle KeyUp event , i'm able to travel. Further when toggling the selection is not working while handling KeyUp event. Andalso i want to auto scroll to set focus to the selected item
HTML Code:
 <CollectionViewSource x:Key="CharacterCollectionView" 
    Source="{Binding}" >
            <PropertyGroupDescription PropertyName="Name" />
            <cm:SortDescription PropertyName="First" />

    <ItemsPanelTemplate x:Key="HorizontalItemsPanel">
        <WrapPanel  Orientation="Horizontal" HorizontalAlignment="Stretch" />

           <Style x:Key="myListboxStyle">
            <!-- 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" />
            <!-- 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" />


    <StackPanel Orientation="Vertical" DockPanel.Dock="Left" Background="#336699" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
        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"  >

            <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}"/>

                    <Trigger Property="IsKeyboardFocusWithin" Value="True">
                        <Setter Property="IsSelected" Value="True" />


                <WrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Background="LightSteelBlue"   />

                <Viewbox Stretch="Fill" HorizontalAlignment="Stretch" >
                    <Border BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding}" BorderBrush="IndianRed"   Margin="0" Height="Auto">
                                Width="150" Margin="5"
                                Height="Auto"  x:Name="Myimage"
                                Source="{Binding Path=ImageFilepath[0]}"/>
                                <Label Content="{Binding Path=Name[0]}" HorizontalContentAlignment="Center" FontWeight="Normal"   FontSize="13"  />

                        <TextBlock Text="{Binding Name}" FontSize="18"  Height="Auto" Background="Transparent" FontWeight="Medium"  />
                        <WrapPanel Orientation="Horizontal"     HorizontalAlignment="Stretch" Background="White"        />

                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <GroupBox Header="{Binding Name}" BorderBrush="#336699" BorderThickness="2" Margin="5">
                                            <ItemsPresenter />

    <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"  />
        Width="300" Orientation="Horizontal"  
        Value="200" Background="PowderBlue"      
        Minimum="150" Maximum="250"
        IsMoveToPointEnabled="False" />

            <TextBlock Width="Auto" Text="{Binding Value, ElementName=sizeSlider}" Foreground="White" FontWeight="Bold" FontSize="14"  Margin="2" Padding="0" />
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple adrotators with multiple images srkarthik_82 ASP.NET 2.0 Professional 4 December 5th, 2007 11:36 PM
Select the all itmes in listbox by pressing Ctrl+ gmbalaa General .NET 1 August 22nd, 2007 02:17 AM
How to load multiple Images on the Form? shah123 C# 1 May 20th, 2007 09:28 PM
Uploading multiple images Adam H-W Classic ASP Basics 0 April 26th, 2007 04:18 AM
Ctrl Click with SELECT MULTIPLE rweide HTML Code Clinic 4 October 5th, 2004 12:14 PM

All times are GMT -4. The time now is 01:52 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.