2011-04-06 90 views

回答

4

你可以风格它像别的:

<Style TargetType="{x:Type ComboBox}" x:Key="HoverBox"> 
    <Style.Triggers> 
     <Trigger Property="IsMouseOver" Value="True"> 
      <Setter Property="Background" Value="Blue" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

用法:

<ComboBox Style="{StaticResource HoverBox}" ... /> 

而在你的用户控件/窗口的顶部,你必须把作风:

<UserControl...> 
    <UserControl.Resources> 

     <Style TargetType="{x:Type ComboBox}" x:Key="HoverBox"> 
      <Style.Triggers> 
       <Trigger Property="IsMouseOver" Value="True"> 
        <Setter Property="Background" Value="Blue" /> 
       </Trigger> 
      </Style.Triggers> 
     </Style> 

    </UserControl.Resources> 

[CONTENT HERE] 

</UserControl> 
+0

我把你写的组合框内的样式。但它给了我一个例外,在x:Key上说:“Key属性只能用于包含在IDictionary类型属性中的标签” – KMC 2011-04-06 08:52:52

+0

感谢您的付出。我照你所说的做了,但组合框仍然得到旧的按钮背景。 – KMC 2011-04-06 09:03:15

+0

你可以设置IsEditable为true ...也许这是你想要的? – Tokk 2011-04-06 09:07:14