WPF Applying a trigger on binding failure

This question is a follow on from this one...

I am binding to a heterogeneous collection of objects, not all objects have the same set of properties. I am doing this in a datagrid. I would like to gray out the cell if the binding fails. Is there a way to apply a trigger if a binding fails?

EDIT: The answer below was suitable for my purposes, but i followed up with this question because I would like to know how to do it (in a non hack fashion - i do love the hack however, don't get me wrong)


As far as I know, you can't do this directly. However, if you can identify a value that will never be returned from successful bindings, you can create a DataTrigger whose binding has that value as its FallbackValue, and trigger on that same value:

<!-- Hibble returns only positive values --> <DataTrigger Binding="{Binding Hibble, FallbackValue=-1}" Value="-1"> <Setter Property="Background" Value="Red" /> </DataTrigger>

In theory it might be possible to omit the FallbackValue and trigger on {x:Static DependencyProperty.UnsetValue}, which would be much cleaner, but this doesn't appear to work in practice.


  • How to handle the JAVA WatchService Overflow event?
  • Haskell: List Created Evaluating List Elements
  • Get entry assembly from ASP.NET application [duplicate]
  • How can I spawn a long running process in a Perl CGI script?
  • Can't get any output from the taglib
  • Disable div click on Ajax start and re-enable it on Ajax complete
  • Add class element based on the name of the page
  • 2-table interaction: insert, get result, insert
  • Is there an HTML code that can make my background picture transparent and my text non-transparent?
  • Implementation of RTTI using typeid
  • Update varbinary(MAX) field in SQLServer 2012 Lost Last 4 bits
  • jQuery - resize an elements height to match window without refreshing, on window resize
  • How to create two column output from a single column
  • Scanner nextInt() and hasNextInt() problems
  • CSS bleed-through with cfinput type=“datefield”
  • ThreadStatic in asynchronous ASP.NET Web API
  • Android changing fragment order inside FragmentPagerAdapter
  • Why use database factory in asp.net mvc?
  • How to add a focus style to an editable ComboBox in WPF
  • converting text file into xml using php?
  • Reduction and collapse clauses in OMP have some confusing points
  • Unable to install Git-core+svn by MacPorts
  • custom UITableViewCell with image for highlighting
  • Caching attributes in superclass
  • MongoDb aggregation
  • How to use remove-erase idiom for removing empty vectors in a vector?
  • Is it possible to access block's scope in method?
  • Meteor: Do Something On Email Verification Confirmation
  • Django: Count of Group Elements
  • SignalR .NET Client Invoke throws an exception
  • Fetching methods from BroadcastReceiver to update UI
  • Bug in WPF DataGrid
  • Where to put my custom functions in Wordpress?
  • Symfony2: How to get request parameter
  • Jquery - Jquery Wysiwyg return html as a string
  • GridView Sorting works once only
  • RestKit - RKRequestDelegate does not exist
  • Arrays break string types in Julia
  • Java static initializers and reflection
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass