Change ListBoxItem Background Color when mouse is over on the listBoxItem

后端 未结 1 1542
刺人心
刺人心 2021-01-26 21:08

I need to set change background color for list item when mouse is over. Here is my code:

    

        
相关标签:
1条回答
  • 2021-01-26 21:45

    How about a Trigger such as:

    <DataTemplate x:Key="ListBoxSubCategoryListTemplate" DataType="{x:Type ListBoxItem}"> 
        <StackPanel> 
            <Button x:Name="btnSubCategoryList" Template="{StaticResource subCategoryListItems}"  
                    Content="{Binding Path=sub_category_name}"  
                    Background="Transparent" 
                    Height="25"/> 
        </StackPanel> 
        <DataTemplate.Triggers> 
            <Trigger Property="IsMouseOver" Value="True"> 
                <Setter TargetName="btnSubCategoryList" Property="Background" Value="Blue" /> 
            </Trigger> 
        </DataTemplate.Triggers> 
    </DataTemplate> 
    
    0 讨论(0)
提交回复
热议问题