【发布时间】:2015-07-20 09:09:09
【问题描述】:
在我们的应用程序中,我们有一个可点击的标签,它会弹出另一个窗口。我一直在阅读 Microsoft 自动化 UI 文档,但找不到能够单击标签控件的方法。
我知道我不能使用调用模式,因为它只处理按钮控件。
以下是我们拥有的 XAML 中的代码
<Label Name="LblCompleteOrdersCount" Content="{Binding CompleteOrders, Mode=OneWay}" Margin="434,45,0,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>
【问题讨论】:
-
是什么让你选择了 Label 而不是 Button?有什么特殊的功能权重有利于 Label?
-
@Maximus 标签用于显示我们拥有的完整订单的数量。我们的企业需要一种方法,让他们可以轻松查看完整订单的数量(以及每个订单的摘要),以便他们可以将这些订单导出到 Excel 表格中。
-
而 Button 没有这个能力?
-
@Maximus 我们可以放一个按钮,但是我们需要标签来显示完成的订单数量。
-
使用 then 按钮,覆盖默认模板并使其看起来像标签。如果 Label 仅提供 Button 但缺少 UI 测试支持,我认为没有必要乱来。
标签: c# wpf microsoft-ui-automation