<DataTemplate>
<Image Name="ServerImageSetter" Source="{svg2Xaml:SvgImage ServerAdministrator2;component/Images/test1.svg}"/>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding ServerKindTrigger}" Value="0">
<Setter TargetName="ServerImageSetter" Property="Source" Value="{svg2Xaml:SvgImage ServerAdministrator2;component/Images/test2.svg}"/>
</DataTrigger>
<DataTrigger Binding="{Binding ServerKindTrigger}" Value="1">
<Setter TargetName="ServerImageSetter" Property="Source" Value="{svg2Xaml:SvgImage ServerAdministrator2;component/Images/test3.svg}"/>
</DataTrigger>
<DataTrigger Binding="{Binding ServerKindTrigger}" Value="2">
<Setter TargetName="ServerImageSetter" Property="Source" Value="{svg2Xaml:SvgImage ServerAdministrator2;component/Images/test3.svg}"/>
</DataTrigger>
</DataTemplate
在我的C#代碼中,我將我的值的類型切換爲0-2,並且應該更改圖像。但這種改變不起作用。DataTemplate不會改變圖片
public int ServerKindTrigger
{
get { return _serverKindTrigger; }
set { _serverKindTrigger = value;
RaisePropertyChanged();
}
}
//Here I switch my serverkind and wanna change the image value
switch (_serverKind)
{
case Servers.test: _serverKindTrigger = 0;
如果分配新的值變量'_serverKindTrigger',不提高的通知。通過屬性來實現:'ServerKindTrigger = 0;'。 – ASh