accessing a resource dictionary in code wpf

后端 未结 2 1223
时光说笑
时光说笑 2021-02-18 22:49

The same line of code in the same assembly works for one test fixture but not another. Here is the line of code:

var dic = new ResourceDictionary { Source = new          


        
2条回答
  •  无人共我
    2021-02-18 23:11

    @Prince Ashitaka answer tells you how to correct your URI

    However the preferred way of accessing a ResourceDictionary is that in XAML you add it on as a merged dictionary

    
        
            
                
            
        
    
    

    then you can access it via code using the TryFindResource(string Key) from any code behind file

提交回复
热议问题