How to I implement dragging up or down a bar or line on the WPF chart?
Currently, this is not possible. You need to change the value of the data source.
So... A two-way binding defined within the XAML is not possible? Only code-behind/attached properties will allow me to update the active record in my xamdatagrid. True/False?
Thx
You can use:
TestDataItem dataItem = this.selectedDataPoint.DataContext as TestDataItem;
Or this...
if ( selectedDataPoint == null ) return;var index = ( (Series) selectedDataPoint.Parent ).DataPoints.IndexOf(selectedDataPoint);var dataItem = ( (IEnumerable<TestDataItem>) ( (Series) selectedDataPoint.Parent ).DataSource ).ElementAt(index);
I added this code to my mouse button up event handler. It works, but it is kind of smelly to me. Two-Way binding would be much clearner.
var fieldInfo = typeof (DataPoint).GetField("_oldBindingObject", BindingFlags.NonPublic | BindingFlags.Instance);if ( fieldInfo != null ){ var dataItem = (TestDataItem) fieldInfo.GetValue(selectedDataPoint); dataItem.Value = selectedDataPoint.Value; selectedDataPoint.ToolTip = dataItem.Tooltip;}