53413

What would be an alternative to x:Reference?

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?

Answer1:

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

{Binding IsChecked, ElementName=DisplayIndicator}

Answer2:

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.

Recommend

  • Android video crop using ffmpeg
  • Using ListPicker and DataBinding
  • Qpython unicode strings
  • creating background processes in php for long running process
  • Does derived class' member functions inherit virtualness from base class?
  • Binding Selected RowCount to TextBlock not Firing OnPropertyChanged after DataGrid Scroll
  • Are channel sends preemption points for goroutine scheduling?
  • How does one get div content line-by-line with Javascript?
  • Php Curl HTTP POST REQUEST set custom header with nested key value pairs
  • Problem serializing DecimalFormatSymbols in 2.3.4
  • R encoding ASCII backtick
  • Reading in Russian characters (Unicode) using a basic_ifstream
  • Is it possilbe to automatically submit a php form
  • How do I use cURL & PHP to spoof the referrer?
  • 403 forbidden error while sending messages to facebook connector through Unification Engine API
  • Serverless Framework Dynamo DB Table Resource Definition with Sort Key
  • Set step size polar plot matplotlib python
  • Caliburn Micro, How to use ContentControl (or display 'sub' ViewModel) using ViewModel Fir
  • How Get arguments value using inline assembly in C without Glibc?
  • Floated image with variable width and heading with background image
  • Android Studio Can't Find tools.jar
  • How to detect interior vertices in groups of 2d polygons? (E.g. ZIP Codes to determine a territory)
  • how to display data from 1st point on words on y axis for line chart in d3.js
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Disable Enter in editText android
  • Change multiple background-images with jQuery
  • How reduce the height of an mschart by breaking up the y-axis
  • How to check if every primary key value is being referenced as foreign key in another table
  • ActionScript 2 vs ActionScript 3 performance
  • To display the title for the current loaction in map in iphone
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Traverse Array and Display in markup
  • Load html files in TinyMce
  • python regex in pyparsing
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • embed rChart in Markdown
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app