WPF - Data Binding Examples

邮差的信 提交于 2020-01-14 12:48:06

问题


I am trying to wrap my arms around WPF binding. I feel like if I can really understand how this works, I can take full advantage of WPF. I recently came across the following, on StackOverflow, that really helped me understand one particular aspect of binding. It is as follows:

<ListView ItemsSource="{Binding AllRoles, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" Name="Hello">

Which means: "Look at my ancestry until you find a Window, then look for a public property on the window called AllRoles". Bind that to the List.

Does anyone know where I can find more very simple examples with explanations like this? I found this extremely useful.


回答1:


WPF Data Binding Cheat Sheet

This did it for me. It has examples for most aspects of data binding in WPF. I kept a printed copy with me when I was starting with WPF and it really did help.

Though 90% of bindings I use are simple {Binding Something} or {Binding ElementName=someElement}, it great to know all the possibilities.




回答2:


I found Bea Stollnitz's blog to have lots of really useful stuff

http://bea.stollnitz.com/blog/



来源:https://stackoverflow.com/questions/5070738/wpf-data-binding-examples

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