Can't see if CanClick is false in WPF
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.
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:
<Style
x:Key="HyperlinkStyle"
TargetType="{x:Type Hyperlink}"
BasedOn="{StaticResource {x:Type Hyperlink}}">
精彩评论