绑定到DataTemplate资源内的元素

时间:2019-05-23 10:47:57

标签: wpf

我想绑定到DataTemplate内部定义的元素,它是一种资源。我该怎么做?:

 <UserControl.Resources>
     <DataTemplate x:Key="DefaultTemplate">
         <!-- I can bind easily from here, but not the other way around... -->
         <Border x:Name="Test" Height="50" />
     </DataTemplate>
 </UserControl.Resources>

 <Grid>
     <ContentControl ContentTemplate="{StaticResource DefaultTemplate}"/>
     <!-- How to bind height to "Test" height? -->
     <Border Height="I would like to bind height to Test element in DefaultTemplate" />
 </Grid>

0 个答案:

没有答案