Change color icon in the ListView UWP

Anderson Cavalcante 21 Reputation points
2022-06-29T14:02:47.53+00:00

How can I change states color (PointerOver, SelectedForeground...) in BitmapIcon inside listView? I'd like the icon be same color as the text.
216174-image.png

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,851 Reputation points
    2022-06-30T06:21:13.833+00:00

    Hello,
    Welcome to Microsoft Q&A!

    Change color icon in the ListView UWP

    For your requirement, the better way is using
    XamlBehaviors to edit the property witin DataTempate. You could use EventTriggerBehavior to detect the pointer hover event then edit icon's Foreground property. For the detail please refer the following code.

    <!--<Core:EventTriggerBehavior EventName="PointerEntered" SourceObject="{Binding ElementName=GridPanel}">  
     <Core:ChangePropertyAction  
            PropertyName="Foreground"  
            TargetObject="{Binding ElementName=MyIcon}"  
            Value="Red"  
            />  
          
    </Core:EventTriggerBehavior>-->  
      
    <!--<Core:EventTriggerBehavior EventName="PointerExited" SourceObject="{Binding ElementName=GridPanel}">  
            <Core:ChangePropertyAction  
            PropertyName="Foreground"  
            TargetObject="{Binding ElementName=MyIcon}"  
            Value="Black"  
            />  
    </Core:EventTriggerBehavior>-->  
      
    

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful