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)?
screenshot
alas not.
i want to translate the error bars by an amount equal to the "bid" property in the bound object. in the attached project, i changed the "bid" to 10 in the object, but the error bars don't move.
Normal 0 false false false MicrosoftInternetExplorer4
<TranslateTransform Y="{Binding Bid}" />
Has it eve been fixed?
Does MarkerTemplate support DataContext now?
thanks!
i can get something similar to what i want by blending the stock chart with the line chart, but my data is really scatter data so this isn't an ideal solution.
unfortunately the DataContext is not available in the MarkerTemplate as you expect it to be. the chart doesn't seem to be designed to work like that, as MarkerTemplate does not derive from FrameworkElement and thus does not have a DataContext property. however, i believe your scenario should be supported exactly the way you expect it to be.
I entered this as a bug, # 23931. feel free to contact Infragistics Developer Support or post back here to inquire about the status of this issue.