|
WPF: Не работает задержка привязки ListBox-а к источнику значений.
|
|||
---|---|---|---|
#18+
Привязал ListBox.ItemsSource к ObservableCollection с задержкой. Задержка не отрабатывает - добавляешь элемент в коллекцию - добавляется сразу в список. Кто-нить сталкивался? Код: xml 1.
... |
|||
:
Нравится:
Не нравится:
|
|||
18.08.2015, 22:24 |
|
WPF: Не работает задержка привязки ListBox-а к источнику значений.
|
|||
---|---|---|---|
#18+
Читайте внимательнее MSDN: When you use a binding to update the binding source whenever the value of the property changes on the target, you set the Mode property to TwoWay and the UpdateSourceTrigger to PropertyChanged. In this situation, you can use the Delay property to specify whether there should be a time delay between when the target is changed and when the source is updated. This is useful when you want to enable users to change a property on a source object but you don't want each change to be immediately committed to the source. For example, suppose that you have a text box that is data two-way bound to a property of a data object. When the user changes the value in the text box, the source gets updated. To enable this scenario, you set the Mode property on the Binding to TwoWay and the UpdateSourceTrigger to PropertyChanged. To avoid updating the source object with every keystroke, set the Delay property to a reasonable value to cause the binding to update only after that amount of time has elapsed since the user stopped typing. https://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.delay(v=vs.110).aspx Т.е. Delay работает 1) только на two-way биндингах; 2) только в направлении от target к source, но не наоборот: Код: xml 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17.
Код: c# 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39.
- в это примере видно, что изменения значения в TextBox'е, прибинденного к свойству Value модели, вызывает изменения свойства с указанной задержкой, а изменение значения свойства модели по команде вызывает изменение значения в TextBox'е сразу же. Всё в соответствии с документацией. ... |
|||
:
Нравится:
Не нравится:
|
|||
19.08.2015, 06:39 |
|
WPF: Не работает задержка привязки ListBox-а к источнику значений.
|
|||
---|---|---|---|
#18+
Спасибо. МакДональд не счел нужным упомянуть об этих важных нюансах в своем учебнике, а я не догадался полезть в MSDN, посчитав, что смысл параметра прост, как валенок, уж тут-то какие могут быть нюансы )) ... |
|||
:
Нравится:
Не нравится:
|
|||
19.08.2015, 08:42 |
|
|
start [/forum/topic.php?fid=21&msg=39031939&tid=1440817]: |
0ms |
get settings: |
8ms |
get forum list: |
14ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
148ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
45ms |
get tp. blocked users: |
1ms |
others: | 255ms |
total: | 493ms |
0 / 0 |