Problem with data binding (Using the MVVM pattern) to a WPF Combobox within a DataGrid's RowDetailsTemplate

笑着哭i 提交于 2019-12-10 12:18:21

问题


I'm trying to bind a view model property to the 'SelectedItem' attribute of a WPF combobox. This combobox resides within a RowDetailsTemplate of a DataGrid. The binding is partially there because the view model's property getter and setter each get called once when a row is selected (And thus causes the details view to expand). However the property never gets called again upon subsequent combobox selection changes. It's almost like the data context is not right after the row details is expanded or the binding is de-coupled after the row details is shown. Very strange, and I can't figure out how to get it to call the property upon all selection changes. There has to be a way.

I know this problem is due to the fact that the combobox is in the row details, but I can't figure out how to get it resolved. Has anybody ever had a problem similar to this? Any and I mean any kind of info or help would be much appreciated ... i've spent a few days hacking away at this trying to figure out why it's behaving this way.


回答1:


Maybe the UpdateSourceTrigger in the Binding is not set to PropertyChanged?



来源:https://stackoverflow.com/questions/3214572/problem-with-data-binding-using-the-mvvm-pattern-to-a-wpf-combobox-within-a-da

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!