views:

35

answers:

2

I have the following singleton class which contains the following property:

public class Manager : INotifyPropertyChanged
{
    public bool IsOnline
    ...

    public static Manager Instance
    ...
}

In the mark-up I am trying to change the color of a button based on this online property:

<Button.Style>
 <Style TargetType="{x:Type Button}">
  <Style.Triggers>
   <DataTrigger Value="True">
    <DataTrigger.Binding>
     <Binding Source="{x:Static storage:Manager.Instance}" Path="IsOnline"/>
    </DataTrigger.Binding>
    <Setter Property="Background" Value="#8000FF00"/>
   </DataTrigger>
  </Style.Triggers>
 </Style>
</Button.Style>

This binding <Binding Source="{x:Static storage:Manager.Instance}" Path="IsOnline"/> fails with the exception:

Cannot convert the value in attribute 'Source' to object of type 'System.Windows.Markup.StaticExtension'.

I have quadruple-checked the "storage" namespace; I know it is both referenced and correct. The Instance property is static, so I do not understand why this binding would fail. I have similar bindings to static properties all over that work just fine.

Any ideas?

A: 

Have you tried using a ValueConverter to inspect the value that the StaticExtension is getting? (See method 2 on this page)

RyanHennig
This is a run-time exception generated on start-up as soon as the button is loaded. It never makes it to the value converter.
Charlie
A: 

I've built a sample app that does exactly what you're describing, it works with no issues. You can download it here.

robertos
I'm going to assume it's something with the control library we're using (Infragistics). In my posted code example I simplified it to a button but it is actually an Infragistics ToggleButton. I guess that isolates the problem to that, doesn't it? ;)
Charlie
The easiest way to know is to get my sample code and change the Button by an Infragistics ToggleButton...
robertos