WPF Image Dynamically changing Image source during runtime

前端 未结 6 1712
情深已故
情深已故 2020-12-09 02:59

I have a window with a title on it. When the user selects a choice from a drop down list, the title image can change. The problem is when the image loads, it\'s a blurred, s

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 03:25

    Here is how it worked beautifully for me. In the window resources add the image.

       
        
         
        
       
    

    Then the code goes like this.

    Image img = new Image()
    
    img.Source = ((Image)this.Resources["delImg"]).Source;
    

    "this" is referring to the Window object

提交回复
热议问题