标签:nbsp horizon code win ping 默认 ica src com
用户控件:
<UserControl> <Grid> <TextBox x:Name="textBlock" HorizontalAlignment="Center" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Center" Width="100" Height="30"/> </Grid> </UserControl>
主窗体:
<Window> <Grid> <local:UserControl1 MouseWheel="UserControl1_MouseWheel"/> </Grid> </Window>
效果:
只有鼠标在TextBox控件上时,才会触发MouseWheel事件(因为UserControl.Background默认Null)。
将Background设为不为Null时,即可在UserControl范围触发MouseWheel事件:
<Window> <Grid> <local:UserControl1 MouseWheel="UserControl1_MouseWheel" Background="SteelBlue"/> </Grid> </Window>
[WPF]UserControl的MouseWheel事件触发
标签:nbsp horizon code win ping 默认 ica src com
原文地址:http://www.cnblogs.com/youliao/p/6168661.html