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.
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>