Set DataContext in XAML

前端 未结 2 1167
一个人的身影
一个人的身影 2021-01-03 00:35

I have this simple application that adds some items to a combobox:

public partial class Window1 : Window
    {
        private ObservableCollection

        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-03 00:55

    I believe the DataContext in this scenario is implicit and does not have to be set since you are using the code behind. If you were using MVVM you would add a reference to that folder and class inside of you XAML markup and set the resource key equal to a value that can then be declared as the DataContext inside of a child elements DataContext property. But in your case (since you are not using MVVM) you shouldn't have to do that.

提交回复
热议问题