2

I have XAML that looks as follows:

<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>

My understanding is that x:Reference is not widely supported yet. However, this is the only way I was able to bind to the desired property (DisplayIndicator), as shown in the screen shot. Can someone suggest an alternative to x:Reference that will work in this situation?

Randy Minder
  • 47,200
  • 49
  • 204
  • 358

2 Answers2

2

Often you can use an ElementName binding, however x:Reference is actually well supported.

{Binding IsChecked, ElementName=DisplayIndicator}
H.B.
  • 166,899
  • 29
  • 327
  • 400
0

Also, as an alternative to direct binding, you could bind both the Checkbox.IsChecked and the Chart.IndicatorEnabled enabled to a property (e.g. ChartDisplayMarkers) on your viewmodel.

Eren Ersönmez
  • 38,383
  • 7
  • 71
  • 92