WPF 绑定父类属性

1.绑定父控件的属性.

1 <ContextMenu x:Key="ContextMenuColoum">
2             <MenuItem Header="复制"    Tag="{Binding Path=Text,RelativeSource={  RelativeSource  Mode=FindAncestor, AncestorType={x:Type TextBlock}, AncestorLevel=1 }}"   Click="MenCopy_Click" >
3                 <MenuItem.CommandBindings>
4                     <CommandBinding CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed" Command="Copy">
5                     </CommandBinding>
6                 </MenuItem.CommandBindings>
7             </MenuItem>
8         </ContextMenu>
9         

发现问题,父控件的属性如果是后期加载的,别如说Width或者Height不是固定的数值,那么绑定时没有效果的。

2.放窗口的大小发生改变,比如最大化,或者正常,Canvas的定位会出现偏差,解决方法?

放弃使用定位方式。。就是没有找到解决办法。。。太菜了我。

posted @ 2013-05-03 14:19  蘑菇mr  阅读(1685)  评论(0编辑  收藏  举报