Binding objects defined in code-behind

前端 未结 11 1290
难免孤独
难免孤独 2020-11-28 04:29

I have some object that is instantiated in code behind, for instance, the XAML is called window.xaml and within the window.xaml.cs

protected Dictionary

        
11条回答
  •  情歌与酒
    2020-11-28 04:46

    In your code behind, set the window's DataContext to the dictionary. In your XAML, you can write:

    
    

    This will bind the ListView to the dictionary.

    For more complex scenarios, this would be a subset of techniques behind the MVVM pattern.

提交回复
热议问题