我的 XAML 如下所示:
<DataTemplate x:Key="CdTeThickness">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row = "0" Orientation="Horizontal">
<CheckBox x:Name="DisplayMarkers" Content="Display Data Points" Margin="8,5,0,5" HorizontalAlignment="Left" IsChecked="False"/>
<CheckBox x:Name="DisplayIndicator" Content="Display Indicator" Margin="8,5,0,5" HorizontalAlignment="Left" IsChecked="False"/>
</StackPanel>
<vf:Chart Grid.Row = "1" Style="{StaticResource chartStyle}" IndicatorEnabled="{Binding Source={x:Reference DisplayIndicator}, Path=IsChecked}">
<vf:Chart.Titles>
<vf:Title Text="{Binding Chart.ChartTitle}"/>
</vf:Chart.Titles>
我的理解是 x:Reference 尚未得到广泛支持。但是,这是我能够绑定(bind)到所需属性 (DisplayIndicator) 的唯一方法,如屏幕截图所示。有人可以建议在这种情况下使用 x:Reference 的替代方案吗?
最佳答案
通常您可以使用ElementName
然而具有约束力x:Reference
实际上得到了很好的支持。
{Binding IsChecked, ElementName=DisplayIndicator}
关于wpf - x :Reference? 的替代品是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10653585/