WPF Setting Image.Source from DataTrigger

Steve picture Steve · Jan 19, 2010 · Viewed 12.2k times · Source

I'm trying to define a DataTrigger for an Image element so that it shows a connected/disconnected image. I keep getting an Invalid PropertyDescriptor message. Any ideas?

<Image>
    <Image.Style>
      <Style>
        <Style.Triggers>
          <DataTrigger Binding="{Binding Source={x:Static my:Server.Instance}, Path=Connected, Mode=OneWay}"
                       Value="True">
            <Setter Property="Source"
                    Value="serverconnected.png"/>
          </DataTrigger>

        </Style.Triggers>
      </Style>
    </Image.Style>
</Image>

Answer

Steve picture Steve · Jan 19, 2010

I just changed Property="Source" to Property="Image.Source" and it's working. Thanks everyone