WPF use binding to assign static resource

前端 未结 2 1322
一向
一向 2021-02-12 13:16

I am trying to use an enum to display a corresponding image. For this I have a value converter that converts an enum to the correct resource name. My resources are defined as fo

2条回答
  •  花落未央
    2021-02-12 13:25

    You cannot bind the StaticResource Key as it is not the DependancyProperty. Either you will have to Bind Source directly to the enum using converter and update the converter code to return the Bitmap itself.

    Second option will be to used Triggers to set the Source property depending on the enum value.

    
       
          
       
    
    

提交回复
热议问题