我正在尝试将子控件中的元素属性绑定到父窗口中的元素属性,它不起作用..
这是我正在尝试做的事情:

这是不起作用的xaml:
CurrentDate="{Binding ElementName=TimeBar, Path=SelectionStart,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
Run Code Online (Sandbox Code Playgroud)
谢谢.
在用户控件中创建依赖属性,然后在窗口中绑定到它
类似的东西:您可以在 stackoverflow 上找到所有的 DependencyProperty 实现
<YourUsercontrol x:Name="uc">
<YourSomeControl CurrentDate="{Binding ElementName=uc, Path=MyDp}"/>
</YourUsercontrol>
Run Code Online (Sandbox Code Playgroud)
xaml窗口
<Window>
<ElementInParent x:Name="eip" />
<YourUsercontrol MyDp="{Binding ElementName=eip, Path=PropertyFromElementInParent}"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8558 次 |
| 最近记录: |