PreviewMouseDown Event not firing. [native sdk]
Posted: 27 Apr 2021, 07:44
Hi, I have ListBox control whose item is a UserControl. The UserControl contains an Expander control whose style(includes content template) is set from code.
Here's the ListBox control :
and the ItemContainerStyle is:
TileGeneric contains :
I would like to expand the Expander when I click on the ListBox item, but for some reason, the ListBox control and its contents are not capturing any mouse movements or clicks.
I tried using Interaction.Triggers and also tried raising the MouseDown event from code behind but nothing worked. Could you please tell me what might be the reason?
Here's the ListBox control :
Code: Select all
<Grid ClipToBounds="True">
<ListBox x:Name="TrainingItemControl"
ItemsSource="{Binding TrainingTiles}"
ItemContainerStyle= "{Binding TrainingTileContentStyleBinding,
RelativeSource={RelativeSource AncestorType=UserControl},
TargetNullValue={StaticResource TrainingTileContentStyle},
FallbackValue={StaticResource TrainingTileContentStyle}}"
Style="{StaticResource TrainingTileContentHolder}"
SelectedItem="{Binding SelectedTrainingItem}"
SelectedIndex="{Binding SelectedIndex}" Height="650" Width="750"
HorizontalContentAlignment="Center"
ScrollViewer.CanContentScroll="False" ScrollViewer.HorizontalScrollBarVisibility="Hidden" />
</Grid>
Code: Select all
<Style x:Key="TrainingTileContentStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<local:TileGeneric Type="{Binding TileType}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Code: Select all
<Grid x:Name="root" ForceCursor="False" Focusable="True" Height="600" >
<Expander x:Name="ExportExpander" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch" ExpandDirection="Right" IsExpanded="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,
AncestorType={x:Type ListBoxItem}},Path=IsSelected}"/>
</Grid>
I tried using Interaction.Triggers and also tried raising the MouseDown event from code behind but nothing worked. Could you please tell me what might be the reason?