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 136187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:54:31+00:00 2026-05-11T06:54:31+00:00

NOTE I have asked the related question: How to combine DataTrigger and EventTrigger? I

  • 0

NOTE I have asked the related question: How to combine DataTrigger and EventTrigger?

I have a list box containing several items. The item’s class implements INotifyPropertyChanged and has a property IsAvailable. I use that property to indicate unavailable options in the list using a different colour.

However, if a selected item is not available, then the foreground colour should be red.

<ListBox>   <ListBox.Resources>     <DataTemplate DataType='{x:Type local:InstitutionViewModel}'>       <TextBlock Name='Name' Text='{Binding Name}'/>       <DataTemplate.Triggers>         <DataTrigger Binding='{Binding IsAvailable}' Value='False'>           <Setter TargetName='Name' Property='Foreground' Value='#888'/>         </DataTrigger>       </DataTemplate.Triggers>     </DataTemplate>   </ListBox.Resources> </ListBox> 

I use the above data trigger to grey out unavailable items.

The problem I’m facing is that the fact that the item is selected has nothing to do with the underlying data to which the template is bound. What I really want is some kind of multi-trigger that supports both a regular Trigger on a dependency property (ListBoxItem.IsSelected) along with a DataTrigger on the bound data item.

Can this be done without introducing the concept of selection into my view model?

For anyone wondering why I do not disable unavailable items, understand that it is a requirement of the application that unavailable options may be selected. There are actually a few list boxes, and selection in one effects what’s available in the others. I cannot disable the items as the user would not be able to change their minds or explore different combinations if items were disabled based upon earlier selections.

  • 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-11T06:54:32+00:00Added an answer on May 11, 2026 at 6:54 am

    For anyone else who’s up against this problem, I found a solution that works for me. Of course, I’m still interested to see other interesting answers.

    Here’s what I did:

    <MultiDataTrigger>   <MultiDataTrigger.Conditions>     <Condition Binding='{Binding       RelativeSource={         RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},         Path=IsSelected}' Value='True'/>     <Condition Binding='{Binding IsAvailable}' Value='False'/>   </MultiDataTrigger.Conditions>   <Setter TargetName='Name' Property='Foreground' Value='#F00'/> </MultiDataTrigger> 

    There’s nothing special about this being a multi trigger though. If you just wanted to style the selected item differently in your data template, you could use:

    <DataTrigger Binding='{Binding    RelativeSource={     RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},     Path=IsSelected}' Value='True'>   <Setter TargetName='Name' Property='Foreground' Value='#888'/> </DataTrigger> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to my question asked here today on SO. Is there a
This question is related to one I asked previously, see here . As a
This is an offshoot question that's related to another I asked here . I'm
Note - I have not delved very deeply into Apple's iPhone SDK yet. However,
I have the following HTML (note the CSS making the background black and text
I have to give a general note to some huge Java project for which
Note that this function does not have a { and } body. Just a
Note: I am just consuming webservice I have no control over webservice code. So
I have up to 4 files based on this structure (note the prefixes are
I have the VS2005 standard edition and MS says this: Note: The Windows Service

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.