问题
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