Home > Net >  WPF dynamic binding Source Image
WPF dynamic binding Source Image

Time:03-30

I have two pictures added to the project, for the Image of the Source, & lt; Image Source="../images/123 PNG "/& gt;
Now I want to add a key in the ResourceDictionary, let this key can use DynamicResource way of binding to the Source, how to do?

I said not too accurate, for example, a string
Rec. In the xaml ResourceDictionary, there is a key & lt; Sys: String x: Key="Logon" & gt; Login & lt;/sys: String> , and then I in other xaml so write Text attributes of a control, the Text="{DynamicResource Logon}", this Text will be displayed for the login, now I want to the Source of the Image is also like this, if I use a String key, you will be prompted me String cannot be applied to the system. Windows. Media. Imagesource,
Rec. Sys in xaml is so write XMLNS: sys="CLR namespace: System; The assembly=mscorlib ", but how to rec. Xaml can get a system. Windows. Media. Imagesource type of key? Is the key to get ImageSource can & lt; Image Source="{DynamicResource img}"/& gt; ?

  •  Tags:  
  • C#
  • Related