Silverlight鼠标左键按下问题
在 Silverlight 3 项目中,我在边框控件上使用鼠标左键按下事件,但发现即使我单击稍微超出边框(如 5-10 像素)的按钮,该事件也会引发。
以前有人遇到过这个问题吗?
感谢期待!
以下是我们捕获 brdSelect 事件的 XAML:
<Border MouseLeftButtonDown="Grid_Mousedown" x:Name="brdSelect" Grid.Row="1" Grid.Column="1" BorderThickness="0.5" BorderBrush="#FF2D9FD2">
<Grid x:Name="grdSelect" >
<Border x:Name="brdImage" BorderThickness="0" CornerRadius="5" Width="Auto" Height="Auto">
<Image Height="Auto" Width="Auto" Stretch="UniformToFill" x:Name="imgMotive"/>
</Border>
<Image Height="Auto" Stretch="UniformToFill" x:Name="imgtmp" Visibility="Collapsed"/>
</Grid>
</Border>
<Image Height="13" Width="13" Source="../Images/rotate_small.JPG" Stretch="None" x:Name="imgRotate" Grid.Row="0" Grid.Column="3" Visibility="Collapsed"/>
<StackPanel Orientation="Horizontal" d:LayoutOverrides="GridBox" Grid.ColumnSpan="3" Margin="0,0,2,0" Width="32" HorizontalAlignment="Left">
<Image Height="13" Width="13" Source="../Images/delete_small.JPG" Stretch="None" x:Name="imgDelete" Visibility="Collapsed" />
</StackPanel>
<Image Source="../Images/resize_small.JPG" Stretch="None" x:Name="imgResize" Grid.Row="2" Grid.RowSpan="2" Grid.Column="2" Visibility="Collapsed" Opacity="0"/>
</Grid>
<TextBlock x:Name="txtLabel" Height="100" HorizontalAlignment="Left" Margin="-80,0,0,-20" Width="80" Text="X: 0 --- Y: 0" Foreground="Red" TextWrapping="Wrap" Visibility="Collapsed"/>
</Grid>
</Border>
In a Silverlight 3 project I am using mouse left button down event on a border control but found out that the event is raised even when I click the button slightly outside the border like 5-10 pixels.
Has anyone faced this issue before?
Thanks in anticipation!
Following is the XAML in which we are capturing the event of brdSelect:
<Border MouseLeftButtonDown="Grid_Mousedown" x:Name="brdSelect" Grid.Row="1" Grid.Column="1" BorderThickness="0.5" BorderBrush="#FF2D9FD2">
<Grid x:Name="grdSelect" >
<Border x:Name="brdImage" BorderThickness="0" CornerRadius="5" Width="Auto" Height="Auto">
<Image Height="Auto" Width="Auto" Stretch="UniformToFill" x:Name="imgMotive"/>
</Border>
<Image Height="Auto" Stretch="UniformToFill" x:Name="imgtmp" Visibility="Collapsed"/>
</Grid>
</Border>
<Image Height="13" Width="13" Source="../Images/rotate_small.JPG" Stretch="None" x:Name="imgRotate" Grid.Row="0" Grid.Column="3" Visibility="Collapsed"/>
<StackPanel Orientation="Horizontal" d:LayoutOverrides="GridBox" Grid.ColumnSpan="3" Margin="0,0,2,0" Width="32" HorizontalAlignment="Left">
<Image Height="13" Width="13" Source="../Images/delete_small.JPG" Stretch="None" x:Name="imgDelete" Visibility="Collapsed" />
</StackPanel>
<Image Source="../Images/resize_small.JPG" Stretch="None" x:Name="imgResize" Grid.Row="2" Grid.RowSpan="2" Grid.Column="2" Visibility="Collapsed" Opacity="0"/>
</Grid>
<TextBlock x:Name="txtLabel" Height="100" HorizontalAlignment="Left" Margin="-80,0,0,-20" Width="80" Text="X: 0 --- Y: 0" Foreground="Red" TextWrapping="Wrap" Visibility="Collapsed"/>
</Grid>
</Border>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,问题出在
MouseLeftButtonDown
事件处理中。在 MSDN 此处 我发现:您有一个带有
CornerRadius="5"
的子边框。可能此属性实际上会导致子边框接收鼠标事件,但从视觉上看,这不应该发生。虽然这取决于实际的实施,你最好检查一下。As I understand the problem is in
MouseLeftButtonDown
event handling. In MSDN here I found:You have a child border with
CornerRadius="5"
. May be this property actually causes child border to receive mouse event when visually this should not happen. Although this depends on actual implementation and you'd better check this.