O hai!
I'm trying to get some error-bar like things going on in my xamChart, but I'm not having much luck.
My XAML looks like mieux (notice the binding in the first TranslateTransform):
<Chart:XamChart Margin="19,245,23,33" Background="White">
<Chart:XamChart.Resources>
<DataTemplate DataType="{x:Type Chart:MarkerTemplate}">
<Grid>
<Grid.RenderTransform>
</Grid.RenderTransform>
<Rectangle Height="16" Width="1" Stroke="Blue" />
<Rectangle Height="1" Width="6" Stroke="Blue">
<Rectangle.RenderTransform>
<TranslateTransform Y="8" />
</Rectangle.RenderTransform>
</Rectangle>
<TranslateTransform Y="-8" />
</Grid>
</DataTemplate>
</Chart:XamChart.Resources>
<Chart:XamChart.Series>
<Chart:Series ChartType="ScatterLine" DataSource="{Binding Smile}" DataMapping="ValueX=Strike; ValueY=Fair">
<Chart:Series.Marker>
<Chart:Marker Foreground="Transparent" UseDataTemplate="True" />
</Chart:Series.Marker>
</Chart:Series>
</Chart:XamChart.Series>
</Chart:XamChart>
And I'm binding points in the chart to objects that look a little something like this:
class PriceVM : DependencyObject
{
public float Strike
get { return (float)GetValue(StrikeProperty); }
set { SetValue(StrikeProperty, value); }
}
// Using a DependencyProperty as the backing store for Strike. This enables animation, styling, binding, etc...
public static readonly DependencyProperty StrikeProperty =
DependencyProperty.Register("Strike", typeof(float), typeof(PriceVM), new UIPropertyMetadata(float.NaN));
public float Bid
get { return (float)GetValue(BidProperty); }
set { SetValue(BidProperty, value); }
// Using a DependencyProperty as the backing store for Bid. This enables animation, styling, binding, etc...
public static readonly DependencyProperty BidProperty =
DependencyProperty.Register("Bid", typeof(float), typeof(PriceVM), new UIPropertyMetadata(float.NaN));
public float Ask
get { return (float)GetValue(AskProperty); }
set { SetValue(AskProperty, value); }
// Using a DependencyProperty as the backing store for Ask. This enables animation, styling, binding, etc...
public static readonly DependencyProperty AskProperty =
DependencyProperty.Register("Ask", typeof(float), typeof(PriceVM), new UIPropertyMetadata(float.NaN));
public float Fair
get { return (float)GetValue(FairProperty); }
set { SetValue(FairProperty, value); }
// Using a DependencyProperty as the backing store for Fair. This enables animation, styling, binding, etc...
public static readonly DependencyProperty FairProperty =
DependencyProperty.Register("Fair", typeof(float), typeof(PriceVM), new UIPropertyMetadata(float.NaN));
But the data binding doesn't get picked up. Is it possible to do this, or am I chasing une hareng rouge (red herring)?
it worked great for me. i'll attach the sample project i put together based on your code.