4

今日私が戦っているのはscrollviewerであり、それが私のイベントをブロックしているという事実です。SO..ここにいくつかの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>

つまり、スクロールビューアー内のグリッドに、ユーザーコントロールの質問をプログラムで追加します...ちなみにクリックイベントのあるボタンがあります。私の問題は、ボタンをクリックできないことです。スクロールビューアーのようです。ユーザーコントロールとボタンを邪悪なマウスから保護するための目に見えない盾のように機能します!

どんな助けにも感謝します!

編集:(これは私の質問ですユーザーコントロール)

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

再編集...間違ったコードが挿入されました...ちょっと眠いです

4

3 に答える 3

5

おそらく、ボタンの前にいくつかのコントロールがあります。コントロールを「スルー」するには、使用できます

IsHitTestVisible="false"

コメントを投稿できますか?

@編集後:RichTextBoxのようで、FlowDocumentがボタンの上にあるようです。グリッドの最後の子としてボタンを追加します。

于 2012-03-12T20:33:01.293 に答える
0

ユーザーコントロールはマウスの左ボタンを処理しているため、クリックしてもコンテンツにアクセスできません。

    MouseLeftButtonDown="IntrebareControl_MouseLeftButtonDown"

そのイベントは発生しますか?

于 2012-03-12T21:20:03.967 に答える
0

誰かがScrollViewerでマウスボタンイベントの発生を妨げる問題も抱えている場合に備えて、対応するUIElementにZIndexを設定することでこれを解決しました。

<TextBlock Text="Hello World!" Panel.ZIndex="2" MouseLeftButtonUp="TextBlockMouseLeftButtonUp"/>
于 2020-04-27T11:02:22.990 に答える