我正在尝试为DataTrigger
元素定义Image
,以便显示已连接/已断开连接的图像。我一直收到Invalid PropertyDescriptor
消息。有什么想法吗?
<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>
答案 0 :(得分:8)
我刚刚将Property =“Source”更改为Property =“Image.Source”并且它正在运行。谢谢大家
答案 1 :(得分:2)
将BitmapImage添加到您的资源中,如下所示:
<BitmapImage x:Key="serverConnected" UriSource="serverconnected.png" />
并更改现有代码以引用它:
<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="{StaticResource serverConnected}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>