I've long been showing a ScatterLineSeries on my RadCartesianChart that uses a MultiBinding in the ItemsSource. I needed this multibinding because the underlying points are expressed in millimeters but the display can be in any units the user chooses and which the user can change. So I have to convert on the fly. So I wrote a converter that takes 5 elements
- An array of points to be converted
- The source X unit
- The source Y unit
- The destination X unit
- The destination Y unit.
It then returns an array of points converted to the appropriate units. This works fine. It looks like this:
<tk:RadCartesianChart.Series> <tk:ScatterLineSeries XValueBinding="X" YValueBinding="Y"> <tk:ScatterLineSeries.ItemsSource> <MultiBinding Converter="{core:PointsLengthConverter}"> <Binding Path="ProfilePoints" /> <Binding Path="SystemService.Millimeter" /> <!-- Source X Unit --> <Binding Path="SystemService.Millimeter" /> <!-- Source Y Unit --> <Binding ElementName="Root" Path="LengthAxisUnit" /> <!-- Dest X Unit --> <Binding ElementName="Root" Path="HeightAxisUnit" /> <!-- Dest Y Unit --> </MultiBinding> </tk:ScatterLineSeries.ItemsSource> </tk:ScatterLineSeries></tk:RadCartesianChart.Series>
However now I need to show several plots on this graph, not just one. But the number varies. So I need to use a ChartSeriesProvider. So I did, with a ScatterSeriesDescriptor. At first it seemed to work -- I got my points -- but then I realized that it iis not converting my points anymore. It is completely ignoring my "ItemsSource" binding in favor the of the "ItemsSourcePath" property in the descriptor.
Here's what it looks like: First I defined a style for each ScatterLineSeries
<Style x:Key="SeriesStyle" TargetType="{x:Type tk:ScatterLineSeries}">
<d:Style.DataContext> <x:Type Type="core:IProfile" /> </d:Style.DataContext> <Setter Property="ItemsSource"> <Setter.Value> <MultiBinding Converter="{core:PointsLengthConverter DebugMode=True}"> <Binding Path="ProfilePoints" /> <Binding Source="{x:Static sdk:LengthUnit.Millimeter}" /> <!-- Source X Unit --> <Binding Source="{x:Static sdk:LengthUnit.Millimeter}" /> <!-- Source Y Unit --> <Binding ElementName="Root" Path="LengthAxisUnit" /> <!-- Dest X Unit --> <Binding ElementName="Root" Path="HeightAxisUnit" /> <!-- Dest Y Unit --> </MultiBinding> </Setter.Value> </Setter></Style>
Then, inside chart, I defined the seriesprovider and descriptor and used that style in it:
<tk:RadCartesianChart.SeriesProvider> <tk:ChartSeriesProvider Source="{Binding Profiles}"> <tk:ChartSeriesProvider.SeriesDescriptors> <tk:ScatterSeriesDescriptor XValuePath="X" YValuePath="Y" ItemsSourcePath="Points" Style="{StaticResource SeriesStyle}"> </tk:ScatterSeriesDescriptor> </tk:ChartSeriesProvider.SeriesDescriptors> </tk:ChartSeriesProvider></tk:RadCartesianChart.SeriesProvider>
Again, this mostly works. My points get plotted. My "SeriesStyle" even gets applied to the ScatterLineSeries (e.g. If I set the stroke to "Yellow" in that style, I see a yellow plotline). But the final element of that style -- ItemsSource -- does NOT get applied. I've tried putting a breakpoint inside the converter. It never gets invoked. So my points all remain in millimeters.
I took a closer look at ScatterSeriesDescriptor, hoping I could find a property that would let me achieve my MultiBinding. I see XValuePath, YValuePath and ItemsSourcePath, and a few other properties ("TypeConverter", "TypePath", etc) but I cannot see any way to apply a MultiBinding to the series of points.
Can you suggest a way I can work around this?
