各种情况下 Data Binding 总结
2010-08-18 14:58
183 查看
绑定到另一个控件的属性
上面这个例子,TextBlock的内容绑定了TextBox,当在TextBox里输入文本是,TextBlock也同时显示
---
绑定到 RelativeSource
---
参考阅读:
http://stackoverflow.com/questions/84278/how-do-i-use-wpf-bindings-with-relativesource
http://www.nbdtech.com/Free/WpfBinding.pdf
---
To be continued ...
<StackPanel> <TextBox x:Name="theTextBox"/> <TextBlock Text="{Binding Text, ElementName=theTextBox}"/> </StackPanel>
上面这个例子,TextBlock的内容绑定了TextBox,当在TextBox里输入文本是,TextBlock也同时显示
---
绑定到 RelativeSource
<ListBox ItemsSource="{Binding MyDataSrc}" Width="200" Padding="0"> <ListBox.ItemTemplate> <DataTemplate> <Grid Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}"> <Button Content="{Binding}"/> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
{Binding Path=xxx, RelativeSource={RelativeSource Self}} {Binding Path=xxx, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type typeXXX}}} {Binding Path=xxx, RelativeSource={RelativeSource TemplatedParent}} {TemplateBinding Path=xxx}
---
参考阅读:
http://stackoverflow.com/questions/84278/how-do-i-use-wpf-bindings-with-relativesource
http://www.nbdtech.com/Free/WpfBinding.pdf
---
To be continued ...
相关文章推荐
- opencv各种内存泄露情况的大总结
- jdbc连接mysql各种情况总结
- opencv各种内存泄露情况的总结
- 各种面试没回音的情况,都给你总结好了!
- opencv各种内存泄露情况的大总结
- mybatis批量更新update的各种情况总结
- 二分查找各种情况大总结
- 二分查找各种情况大总结
- 二分查找各种情况大总结
- 总结手机收不到短信验证码的各种情况
- [置顶] 二分查找各种情况大总结
- 由一道腾讯面试题引发的关于递归函数使用的各种情况总结
- 总结手机收不到短信验证码的各种情况
- C++ 指针 new delete 赋值各种情况总结
- vue2.0组件通信各种情况总结与实例分析
- vue2.0组件通信各种情况总结与实例分析
- flex布局各种情况总结分析及实例演示
- opencv各种内存泄露情况的大总结
- 二分查找各种情况大总结
- TPS波动各种原因总结,做过的项目大概总结下有5中以上情况...