Why do these tabs seem to share the same textbox?

前端 未结 1 469
无人共我
无人共我 2021-01-29 00:43

I defined my UI in xaml and below is my code:



        
相关标签:
1条回答
  • 2021-01-29 01:37

    It seems like your Model implement

    ObservableCollection<MyHomeworkModel>.
    

    Remove this Base class and it should work.

    Edit:

    Your need to change:

           AddCourseCommand = new AddCourseCommand(this);
    

    To

    Download DelegateCommand

           AddCourseCommand = new DelegateCommand(AddNewTab);
    

    Edit:

    You Cut your ViewModel from your UI. You Copy an Instance into your Command and than call on that Copy add. This is wrong and Property your Fault. I realy advice you to use DelegateCommand this will maybe fix it.

    To your guess:

    think I know why it's complaining. My Text property is is MyHomeworkModel not MyHomeworkViewModel...but why it's fine with me binding the header to the Header property in MyHomeworkModel ?

    It is right that your Property is in MyHomeworkModel and not in MyHomeworkViewModel you Bind onto a List that contains MyHomeworkModels. Now is you add a new item your Binding will set in the Lowest level. In this case in your insance of MyHomeworkModel and not in MyHomeworkViewModel

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