How to change the WPF XAML to reflect changes in the C# code-behind?

后端 未结 1 1487
暗喜
暗喜 2021-01-28 17:41

I am refractoring the code from sample:

  • 24.129.21. Master Detail Binding
    from C# / CSharp Tutorial » Windows Presentation Foundation » Binding)
相关标签:
1条回答
  • 2021-01-28 18:23

    In your Window1.xaml class remove the reference to the skills class: (e.g. <local:Skills> ) since you don't have a Skills class anymore. Instead you want a number of Skill elements inside your ObservableCollection:

    <local:Team>
       <local:Employee Name="Larry" Age="21">
         <local:Employee.Skills>
            <local:Skill />
            <local:Skill />
           ....
    

    Also, you should probably initialize the Skills ObservableCollection inside the Employee's constructor.

    0 讨论(0)
提交回复
热议问题