无法查看 WPF 中 CanClick 是否为 false
我有以下 wpf:
<Style x:Key="HyperlinkStyle" TargetType="Hyperlink">
<Setter Property="Foreground"
Value="{StaticResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="TextDecorations" Value="{x:Null}"/>
</Style>
<TextBlock>
<Hyperlink Command="{Binding ClickCommand, Mode=OneTime}"
Style="{StaticResource HyperlinkStyle}">
<StackPanel Orientation="Horizontal">
<Image Margin="0,2,2,0" Source="{Binding Icon}" />
<TextBlock Text="{Binding Text}" />
</StackPanel>
</Hyperlink>
</TextBlock>
问题是您无法查看 ClickCommand 上的 CanClick 是否为 false。
I have following wpf:
<Style x:Key="HyperlinkStyle" TargetType="Hyperlink">
<Setter Property="Foreground"
Value="{StaticResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="TextDecorations" Value="{x:Null}"/>
</Style>
<TextBlock>
<Hyperlink Command="{Binding ClickCommand, Mode=OneTime}"
Style="{StaticResource HyperlinkStyle}">
<StackPanel Orientation="Horizontal">
<Image Margin="0,2,2,0" Source="{Binding Icon}" />
<TextBlock Text="{Binding Text}" />
</StackPanel>
</Hyperlink>
</TextBlock>
The problem is that you can't see if CanClick on the ClickCommand is false.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当超链接的命令为 false 时,它被禁用(IsEnabled 应为 false)。检查情况是否如此,以及子项目是否也被禁用。您是否尝试找出失败的地方?例如,删除您的自定义样式或子元素(用简单的文本替换它们),以便您可以看到问题出在哪里。
编辑:
所以风格就是问题。在这种情况下,请尝试继承默认样式:
When the hyperlink's command is false, it is disabled (IsEnabled should be false). Check that this is the case and that the child items also are disabled. Did you try finding where it fails? For example, remove your custom style or the child elements (replace them with a simple text), so you can see where the problem is.
Edit:
So the style is the problem. In that case, try inheriting from the default style: