0

My requirement is : I have a list view in wpf user control and selection mode is extended. User can selects different ways those are: 1. with shift key 2. with ctrl key 3. with ctrl+left mouse button and drag select.

First and second scenario is working for me. How to achieve the 3 scenario.

I have gone through last answer which is in the below link. But it did not worked for me.

Previous Post

Please help to fix the issue.

Here is my listview:

<ListView BorderThickness="0,0,0,1"                   
              Name="WheeledYardLocation"
              ItemsSource="{Binding lstUser}"
              SelectionMode="Extended"
              HorizontalAlignment="Stretch"
              AutomationProperties.Name="WheeledListView"
              AutomationProperties.AutomationId="WheeledListView"
              SelectedIndex="0"
              AlternationCount="2">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">                   
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <Border Name="root"
                                    Background="Transparent"
                                    BorderThickness="0,0,0,1"
                                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}">                                   
                                <Grid Margin="10,2,0,2"
                                      HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                      Background="Transparent">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="50" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Name="title"
                                               FontSize="14">
                                        <TextBlock.Text>
                                            <MultiBinding StringFormat=" {0}-{1}">
                                                <Binding Path="Id" />
                                                <Binding Path="Name" />
                                            </MultiBinding >
                                        </TextBlock.Text>
                                        <AutomationProperties.AutomationId>
                                            <MultiBinding StringFormat="Block-{0}">
                                                <Binding Path="Age" />
                                            </MultiBinding >
                                        </AutomationProperties.AutomationId>
                                    </TextBlock>
                                    <TextBlock Name="total"
                                               Grid.Column="1"
                                               HorizontalAlignment="Center">
                                        <AutomationProperties.AutomationId>
                                            <MultiBinding StringFormat="TotalAvailable-{0}">
                                                <Binding Path="Age" />
                                            </MultiBinding >
                                        </AutomationProperties.AutomationId>
                                        <Run Text="{Binding Path=Age,  StringFormat=0;;-}" />
                                    </TextBlock>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver"
                                         Value="True">
                                    <Setter Property="Background"
                                            Value="Blue"
                                            TargetName="root" />
                                    <Setter Property="Foreground"
                                            Value="White"
                                            TargetName="title" />
                                    <Setter Property="Foreground"
                                            Value="White"
                                            TargetName="total" />                                        
                                </Trigger>
                                <Trigger Property="IsSelected"
                                         Value="True">
                                    <Setter Property="Background"
                                            Value="Blue"
                                            TargetName="root" />
                                    <Setter Property="Foreground"
                                            Value="White"
                                            TargetName="title" />
                                    <Setter Property="Foreground"
                                            Value="White"
                                            TargetName="total" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>                    
            </Style>
        </ListView.ItemContainerStyle>
    </ListView>
Community
  • 1
  • 1
Sri Forums
  • 11
  • 3
  • That's going to take lots of codebehind, as it isn't a standard UI pattern. –  Dec 11 '15 at 13:54
  • SO. Could you please help to fix the issue? – Sri Forums Dec 14 '15 at 06:48
  • Nope, it's a bit much to achieve, and it's a non-standard UI pattern, which means it's pretty much a waste of time. If you want to do it, start very small. Create a tiny little prototype and start playing with it. You'll have to track key state and mouse down all the time, intercepting drag events, preventing UI elements from getting clicked on, etc etc etc. A complete waste of time. –  Dec 14 '15 at 14:00

0 Answers0