Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 128345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:37:15+00:00 2026-05-11T05:37:15+00:00

I can trigger property settings on my ListBoxItem template based on properties of underlying

  • 0

I can trigger property settings on my ListBoxItem template based on properties of underlying data object using DataTrigger with something like this

<DataTrigger Binding='{Binding Path=IsMouseOver}' Value='true'>   <Setter TargetName='ItemText' Property='TextBlock.TextDecorations' Value='Underline'>   </Setter> </DataTrigger> 

But what if I want to do the opposite? I mean set a property value on the underlying data object based on property value of my ListBoxItem. Something like:

<Trigger Property='IsMouseOver' Value='True'>   <Setter Property='MyClass.IsHilited' Value='True'></Setter> </Trigger> 

Is there a mechanism for something like this or what would be the recommended approach to deal with situations like this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:37:15+00:00Added an answer on May 11, 2026 at 5:37 am

    I think that you could use an EventSetter to do in XAML what Josh G suggested in code. Maybe create one for the MouseEnter and MouseLeave events, and style the control appropriately for each?

    Update: You can set up the events like this:

    <ListBox>     <ListBox.Resources>         <Style TargetType='{x:Type ListBoxItem}'>             <EventSetter Event='MouseEnter' Handler='OnListBoxItemMouseEnter' />             <EventSetter Event='MouseLeave' Handler='OnListBoxItemMouseLeave' />         </Style>     </ListBox.Resources>     <ListBoxItem>Item 1</ListBoxItem>     <ListBoxItem>Item 2</ListBoxItem>     <ListBoxItem>Item 3</ListBoxItem>     <ListBoxItem>Item 4</ListBoxItem>     <ListBoxItem>Item 5</ListBoxItem> </ListBox> 

    The Style registers for the MouseEnter and MouseLeave events for all ListBoxItems defined in that ListBox.

    And then in your code behind file:

    private void OnListBoxItemMouseEnter(object sender, RoutedEventArgs e) {     ListBoxItem lvi = sender as ListBoxItem;     if(null != lvi)     {         lvi.Foreground = new SolidColorBrush(Colors.Red);     } }  private void OnListBoxItemMouseLeave(object sender, RoutedEventArgs e) {     ListBoxItem lvi = sender as ListBoxItem;     if(null != lvi)     {         lvi.Foreground = new SolidColorBrush(Colors.Black);     } } 

    These handlers set the color of the text of the ListBoxItem to red when the mouse is over the item, and back to black when the mouse leaves it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I trigger a stored procedure in SQL Server 2005 based on emails
When using categories in ExpressionEngine, a Category URL Indicator trigger word can be set
Like how the click() can be used to trigger a click event on an
I'm trying to format my ListBoxItem template to include a image. I can add
How can i trigger an event for the scaleX property change of the movieClip
I can position a background image using the background property in an input field
Can I use a trigger on the SelectedItem property in any control that supports
May I know know I can trigger system to repaint nth row in JList?
Can a trigger for a table can be applied for tracking in same table?
How can I trigger the distant element which associates with the current button? For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.