在我们的应用程序中,我们有一个可点击的标签,它将弹出另一个窗口.我一直在阅读Microsoft自动化UI文档,但找不到我能够单击标签控件的方法.
我知道我不能使用Invoke模式,因为它只处理Button控件.
以下是我们拥有的XAML代码
<Label Name="LblCompleteOrdersCount" Content="{Binding CompleteOrders,Mode=OneWay}" Margin="434,45,0" Height="62" Width="170" Padding="0" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Top" FontSize="56" FontWeight="Bold"> <Label.InputBindings> <MouseBinding Command="{Binding Path=CompleteOrdersCommand}" MouseAction="LeftClick" /> </Label.InputBindings> </Label>
解决方法
我的提示是使用Button.它派生自ICommandSource接口,因此您可以毫不费力地使用Command将Button与处理程序相关联.问问自己:Label提供的Button功能不是什么功能?好看?覆盖默认按钮的模板,您将获得相同的外观.只要您不利用Label的任何其他功能,我就会发现没有必要弄乱它.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。