When is x:Reference in WPF resolved and why does XAML element order affect it?

后端 未结 3 1191
小蘑菇
小蘑菇 2021-01-11 20:25

x:Reference can not be resolved after I re-arrange elements in XAML.

Here I present a working code. Just move the DataGrid element so it comes after the button eleme

3条回答
  •  渐次进展
    2021-01-11 21:22

    I suppose it is because your resources(Window.Resources) will be created first, before referenced instance exists. I would try to solve this through DataContext (ViewModel).

    
            
        
    
    

提交回复
热议问题