0
我有一個包含一個包裝面板的主視圖,此包裝包含一個usercontrols列表。如何在使用依賴項屬性時綁定數據
我通過使用DependencyProperty獲取數據到usercontrol中,問題是如何將wpf綁定到usercontrol中的變量?如果我使用
DataContext="{Binding RelativeSource={RelativeSource Self}}"
它似乎從工作
我有一個包含一個包裝面板的主視圖,此包裝包含一個usercontrols列表。如何在使用依賴項屬性時綁定數據
我通過使用DependencyProperty獲取數據到usercontrol中,問題是如何將wpf綁定到usercontrol中的變量?如果我使用
DataContext="{Binding RelativeSource={RelativeSource Self}}"
它似乎從工作
停止的DependencyProperty給你控制一個名字,即:
<UserControl x:Class="YourApp.YourNamespace"
... etc ...
x:Name="_this">
那麼其所有子控件可以綁定到這樣的依賴屬性:
<TextBlock Text={Binding ElementName=_this, Path=YourDependencyPropertyName}" />
請發表相關XAML請 –