Question

These items are in

<ListBox.ItemTemplate> <DataTemplate>

The problem I have is the left click on the first ContentControl does not select the row
Left click the TextBlock does select the row

If I comment out the scrollViewer the it works.
So it appears the ScrollViewer is eating the click.
I am going to try moving the Visibility up to the ScrollView.

visabilityConverterReverse just returns Visible for false and Collapsed for true
when the row is selected i substitute in more characters of the same data

<TextBlock Grid.Row="0" Grid.Column="0" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"                                                         
            Text="{Binding Path=FieldDefApplied.FieldDef.DispName}"/>
<ContentControl Grid.Row="0" Grid.Column="1" Margin="2,0,0,0" Padding="0" MouseRightButtonDown="cc_CopyToClip" FontWeight="Normal"
        Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsSelected, Converter={StaticResource visabilityConverterReverse}}"                                                    
        Content="{Binding Path=DispValueShortRunHighlight, Converter={StaticResource stringToXaml}}"/>
<ScrollViewer Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" Margin="5,0,0,0" Padding="0" 
            HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" MaxHeight="140">
    <ContentControl MouseRightButtonDown="cc_CopyToClip" 
        Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsSelected, Converter={StaticResource bvc}}"
        Content="{Binding Path=DispValueRunHighlight, Converter={StaticResource stringToXaml}}"/>
</ScrollViewer>
Was it helpful?

Solution

I tried this in small sample with scrollViewer and was able to reproduce an issue.

ScrollViewer might be eating up the MouseDown event which doesn't get pass through to the ListBoxItem.


Like I said above here are the snapshots for raised events taken using Snoop.

If you click on first ContentControl, it respond perfectly because MouseDown events make its way to ListBoxItem perfectly hence selecting ListBoxItem. Events flow is summarised below:

enter image description here

But in second case when you click on ContentControl which is inside of ScrollViewer, ScrollViwer eats up the MouseDown event by handling it. Here is the flow for second case:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top