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
Register
Register | 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 28th, 2013, 01: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"

1.When
[ 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}" >
        <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>
Reply With Quote
Reply


Thread Tools
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 10: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 05:15 AM.


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