Scrollviewer blocking events

what I'm struggling today is the scrollviewer and the fact that it blocks my events. SO..here's some xaml:

    <ScrollViewer x:Name="scrollv" Panel.ZIndex="15" Margin="8,65.5,0,22" VerticalScrollBarVisibility="Visible" Height="392.5" Background="White" IsHitTestVisible="False">
        <Grid x:Name="listaintrebari" Height="Auto" Width="301.5" HorizontalAlignment="Left" VerticalAlignment="Top" Background="White" >

        </Grid>

    </ScrollViewer>

      

So the thing is, in the grid that is inside the scrollviewer, I programmatically add UserControl questions ... which accidentally has a button with a click event. My problem is that I cannot press the button. The scrollviewer acts as an invisible screen to protect the user control and button from the evil mouse!

Any help is appreciated!

EDIT: (these are my Usercontrol questions)

   <UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:eHelper_v3"
mc:Ignorable="d"
x:Class="eHelper_v3.questions"
x:Name="IntrebareControl" Width="330.641" Margin="0" MouseLeftButtonDown="IntrebareControl_MouseLeftButtonDown"

>

<Grid x:Name="LayoutRoot" ScrollViewer.VerticalScrollBarVisibility="Disabled" Margin="0,0,13,0" Height="90" >
    <Rectangle x:Name="rect" Panel.ZIndex="20" Height="90" Stroke="#FF0975A3"  >
        <Rectangle.Fill>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#1404BFD8" Offset="0.004"/>
                <GradientStop Color="#1300A7FF" Offset="0.996"/>
                <GradientStop Color="#2B0F82CC" Offset="0.459"/>
            </LinearGradientBrush>
        </Rectangle.Fill>
    </Rectangle>
    <Image x:Name="imagine" HorizontalAlignment="Left" Margin="8,8,0,8" Width="126.667" Stretch="Fill" MouseLeftButtonDown="imagine_MouseLeftButtonDown" />
    <TextBlock x:Name="textul" Margin="138.667,8,8,22.5" TextWrapping="Wrap" Text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" FontSize="9.333"/>
    <Label x:Name="status" Content="Status" Height="22" Margin="127,0,100,0.5" VerticalAlignment="Bottom" FontSize="9.333" Background="#00894848" Foreground="Red"/>
    <Button x:Name="raspundeBtn" Content="Raspunde" HorizontalAlignment="Right" Height="18" Margin="0,0,8,4.5" VerticalAlignment="Bottom" Width="50.974" FontSize="9.333" Click="raspundeBtn_Click"/>

</Grid>

      

REEDITED ... wrong code inserted ... kind of dream here

+3


source to share


2 answers


There may be some controls in front of your button. To click "through" a control, you can use

IsHitTestVisible="false"

      



Can you post your comment on that?

@ after your edit: It seems that your RichTextBox and that the FlowDocument lies over the Button. Add your button as the last child of your grid.

+3


source


The custom control handles the left mouse button to prevent the click from hitting the content.

    MouseLeftButtonDown="IntrebareControl_MouseLeftButtonDown"

      



Is this event recoverable?

0


source







All Articles