MVVM and the TextBox's SelectedText property

前端 未结 3 908
名媛妹妹
名媛妹妹 2020-12-01 09:29

I have a TextBox with a ContextMenu in it. When the user right clicks inside the TextBox and chooses the appropriate MenuItem, I would like to grab the SelectedText in my v

3条回答
  •  天命终不由人
    2020-12-01 10:20

    The sample applications in the WPF Application Framework (WAF) chose another way to solve this issue. There the ViewModel is allowed to access the View through an interface (IView) and so it can request the current SelectedText.

    I believe Binding shouldn’t be used in every scenario. Sometimes writing a few lines in code behind is much cleaner than using highly advanced helper classes. But that’s just my opinion :-)

    jbe

提交回复
热议问题