Nagi A

Nagi A

  • 1.3k
  • 405
  • 12.1k

Could not able to fire events to StackPanel in ScrollViewer

Jan 24 2017 1:58 AM
Could not able to fire events to StackPanel which is inside the ScrollViewer.
we tried with Panel.ZIndex but no luck.
 
Greatly appreciated for help.
 
Window1.xaml file
 
<ScrollViewer Name="xxScrollBar" Panel.ZIndex="0" >
<StackPanel PreviewMouseDown="StackPanel_PreviewMouseDown" Panel.ZIndex="1000" MouseDown="StackPanel_MouseDown">
<Slider x:Name="UpperSlider"
Minimum="{Binding ElementName=root, Path=Minimum}"
Maximum="{Binding ElementName=root, Path=Maximum}"
Value="{Binding ElementName=root, Path=UpperValue, Mode=TwoWay}"
Margin="0,15,0,0" />
<Button x:Name="button1" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"/>
</StackPanel>
</ScrollViewer>
 
Window1.xaml.cs file
 
private void xxScrollBar_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.Source.GetType() == typeof(StackPanel))
{
}
}
private void StackPanel_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Clicked on StackPanel");
}
private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Clicked on StackPanel");
}
 
 

Attachment: WpfApplication1.zip

Answers (2)