2013-07-01 102 views
0

我有ItemsControl 中的Hyperlink元素列表,他們顯示正確,但他們的風格不適用於某種原因,我不明白爲什麼。超鏈接樣式不適用

風格:

<Style TargetType="{x:Type Hyperlink}"> 
    <Style.Triggers> 
     <Trigger Property="IsMouseOver" Value="True"> 
      <Setter Property="Foreground" Value="#CE1C37" /> 
     </Trigger> 
    </Style.Triggers> 
    <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" /> 
    <Setter Property="Foreground" Value="#555555" /> 
</Style> 

它們是如何顯示:

<TextBlock TextWrapping="Wrap" Style="{StaticResource MyTextBlock}" Margin="10,0,0,0"> 
    <Hyperlink Command="{Binding DataContext.TopicSelectedCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" CommandParameter="{Binding}"> 
     <TextBlock Text="{Binding Path=Title}"/> 
    </Hyperlink> 
</TextBlock> 

回答

1

就離開了Style="{StaticResource MyTextBlock}。輸入的樣式不起作用。

IMO你應該已經收到編譯器錯誤。

+0

我試過,但它似乎沒有什麼區別 - 它只適用於我的名字 – Chris

+0

確保樣式定義中沒有'x:Key'(就像在你的問題中一樣)。 – JeffRSon

+0

嘿傑夫 - 沒有任何'x:Key'它不起作用,但是如果我命名它然後它能工作(只要我在'Hyperlink'中指定樣式) – Chris