如何在 XAML 中将一个元素的属性绑定到另一个元素的属性

如何在 XAML 中将一个元素的属性绑定到另一个元素的属性

问题描述:

以下是部分 XAML:

The following is some partial XAML:

<CheckBox Content="Display Data Points?" Margin="8,0.04,0,4" Grid.Row="1" FlowDirection="RightToLeft" d:LayoutOverrides="Height" HorizontalAlignment="Left"/>

<vf:DataSeries RenderAs="Line" DataSource="{Binding CdTeRoughnessList}" XValueType="DateTime" MarkerEnabled="{Binding ???}" Color="Red" LegendText="Roughness Average">

我想将 DataSeries 的 MarkerEnabled 属性绑定到 CheckBox 的 IsChecked 属性.换句话说,当用户选中复选框时,我希望在未选中时将 MarkerEnabled 设置为 True 和 False.

I would like to bind the MarkerEnabled property of the DataSeries to the IsChecked property of the CheckBox. In other words, when the user checks the check box, I want the MarkerEnabled to be set to True and False when unchecked.

这可以做到吗(我几乎可以肯定 WPF 会支持这一点)?如果是这样,我该怎么做?

Can this be done (I'm almost sure WPF would support this)? If so, how might I do it?

给你的 Checkbox 一个名字,然后适当地绑定:

Give your Checkbox a name and then bind appropriately:

<CheckBox x:Name="DisplayDataCheckbox" Content="Display Data Points?"/>

<vf:DataSeries MarkerEnabled="{Binding ElementName=DisplayDataCheckbox, Path=IsChecked}">