Hi, I have problem with binding ObservableCollection on ItemsSource of FinancialIndicator. When I bound CandleChart series, I haven't problem.
<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="IndicatorComboBox" MinWidth="150" Width="Auto" ItemsSource="{Binding IndicatorCollection}" SelectedItem="{Binding SelectedIndicator}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ElementName=IndicatorComboBox,Path=SelectedItem.ApplyPararmetersComand}" CommandParameter="{Binding ElementName=IndicatorChart}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=DisplayName}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!--<ContentPresenter Content="{Binding ElementName=IndicatorComboBox,Path=SelectedItem }" />-->
<Button Content="Apply" Command="{Binding ElementName=IndicatorComboBox,Path=SelectedItem.ApplyPararmetersComand}" CommandParameter="{Binding ElementName=IndicatorChart}" />
</StackPanel>
<ContentPresenter Content="{Binding Path=SelectedIndicator}" />
</StackPanel>
-------
<ControlTemplate x:Key="StohasticIndicator" >
<StackPanel Orientation="Vertical" >
<WrapPanel Orientation="Horizontal">
<TextBlock Text="SignalPeriod:" />
<TextBox Text="{Binding Path=SignalPeriod,Mode=TwoWay}"/>
<TextBlock Text="MainPeriod:" />
<TextBox Text="{Binding Path=MainPeriod,Mode=TwoWay}"/>
<TextBlock Text="Slowing:" />
<TextBox Text="{Binding Path=SlowingPeriod,Mode=TwoWay}"/>
</WrapPanel>
<telerik:RadCartesianChart x:Name="IndicatorChart" DataContext="{Binding}" Visibility="{Binding IndicatorVisibility}" Zoom="{Binding Path=DataContext.IndicatorChartZoom, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}" Width="Auto" >
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeContinuousAxis ShowLabels="True"
MajorStep="{Binding Path=DataContext.MajorStep, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}"
MajorStepUnit="Minute"
LabelInterval="6"
LabelTemplate="{StaticResource axisLabelTemplate}"
PlotMode="OnTicksPadded"
Minimum="{Binding Path=DataContext.MinTime, RelativeSource={RelativeSource AncestorType=vw:CandleChartView,Mode=FindAncestor}}"
Maximum="{Binding Path=DataContext.MaxTime, RelativeSource={RelativeSource AncestorType=vw:CandleChartView,Mode=FindAncestor}}"
>
</telerik:DateTimeContinuousAxis>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis Minimum="0" Maximum="100" LabelInterval="2" />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:RadCartesianChart.Behaviors>
<telerik:ChartPanAndZoomBehavior ZoomMode="None" PanMode="Horizontal" />
</telerik:RadCartesianChart.Behaviors>
<telerik:RadCartesianChart.Series>
<telerik:CandlestickSeries x:Name="s1" ItemsSource="{Binding Path=Source}"
OpenBinding="OpenPrice"
HighBinding="HightPrice"
LowBinding="LowPrice"
CloseBinding="ClosePrice"
CategoryBinding="StartTime" >
</telerik:CandlestickSeries>
</telerik:RadCartesianChart.Series>
<telerik:RadCartesianChart.Indicators >
<!--<telerik:StochasticFastIndicator ItemsSource="{Binding Path=DataContext.Candles, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Blue" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" />-->
<telerik:StochasticFastIndicator ItemsSource="{Binding Path=Source}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Blue" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" />
<telerik:StochasticSlowIndicator ItemsSource="{Binding Path=Source}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Red" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" SlowingPeriod="{Binding SlowingPeriod}" />
</telerik:RadCartesianChart.Indicators>
<telerik:RadCartesianChart.Annotations>
<telerik:CartesianGridLineAnnotation Value="80" Axis="{Binding ElementName=IndicatorChart, Path=VerticalAxis}" StrokeThickness="1" Stroke="Black" Label="80" />
<telerik:CartesianGridLineAnnotation Value="20" Axis="{Binding ElementName=IndicatorChart, Path=VerticalAxis}" StrokeThickness="1" Stroke="Black" Label="20" />
</telerik:RadCartesianChart.Annotations>
</telerik:RadCartesianChart>
</StackPanel>
</ControlTemplate>
<DataTemplate DataType="{x:Type models:StohasticIndicator}">
<Control Template="{StaticResource ResourceKey=StohasticIndicator}" DataContext="{Binding}" />
</DataTemplate>
---------------------
Source is ObservableCollection of Candle , and some times updates from external service.
public class Candle : INotifyPropertyChanged
{
private Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
private double _openPrice;
private double _closePrice;
private double _hightPrice;
private double _lowPrice;
private double _volume;
private DateTimeOffset _startTime;
private DateTimeOffset _endTime;
public double OpenPrice
{
get { return _openPrice; }
set
{
if (value != _openPrice)
{
_openPrice = value;
OnPropertyChanged("OpenPrice");
}
}
}
public double ClosePrice
{
get { return _closePrice; }
set
{
if(value != _closePrice)
{
_closePrice = value;
OnPropertyChanged("ClosePrice");
}
}
}
public double HightPrice
{
get { return _hightPrice; }
set
{
if (value != _hightPrice)
{
_hightPrice = value;
OnPropertyChanged("HightPrice");
}
}
}
public double LowPrice
{
get { return _lowPrice; }
set
{
if (value != _lowPrice)
{
_lowPrice = value;
OnPropertyChanged("LowPrice");
}
}
}
public double Volume
{
get { return _volume; }
set
{
if (_volume != value)
{
_volume = value;
OnPropertyChanged("Volume");
}
}
}
public DateTimeOffset StartTime
{
get { return _startTime; }
set
{
if (_startTime != value)
{
_startTime = value;
OnPropertyChanged("StartTime");
}
}
}
public DateTimeOffset EndTime
{
get { return _endTime; }
set
{
if (_endTime != value)
{
_endTime = value;
OnPropertyChanged("EndTime");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
dispatcher.BeginInvoke(DispatcherPriority.Normal,
(ThreadStart)delegate()
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
});
}
}
}
CandleSeries updates normal, but Financial indicator doesn't work. Help, please :)
<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="IndicatorComboBox" MinWidth="150" Width="Auto" ItemsSource="{Binding IndicatorCollection}" SelectedItem="{Binding SelectedIndicator}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ElementName=IndicatorComboBox,Path=SelectedItem.ApplyPararmetersComand}" CommandParameter="{Binding ElementName=IndicatorChart}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=DisplayName}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!--<ContentPresenter Content="{Binding ElementName=IndicatorComboBox,Path=SelectedItem }" />-->
<Button Content="Apply" Command="{Binding ElementName=IndicatorComboBox,Path=SelectedItem.ApplyPararmetersComand}" CommandParameter="{Binding ElementName=IndicatorChart}" />
</StackPanel>
<ContentPresenter Content="{Binding Path=SelectedIndicator}" />
</StackPanel>
-------
<ControlTemplate x:Key="StohasticIndicator" >
<StackPanel Orientation="Vertical" >
<WrapPanel Orientation="Horizontal">
<TextBlock Text="SignalPeriod:" />
<TextBox Text="{Binding Path=SignalPeriod,Mode=TwoWay}"/>
<TextBlock Text="MainPeriod:" />
<TextBox Text="{Binding Path=MainPeriod,Mode=TwoWay}"/>
<TextBlock Text="Slowing:" />
<TextBox Text="{Binding Path=SlowingPeriod,Mode=TwoWay}"/>
</WrapPanel>
<telerik:RadCartesianChart x:Name="IndicatorChart" DataContext="{Binding}" Visibility="{Binding IndicatorVisibility}" Zoom="{Binding Path=DataContext.IndicatorChartZoom, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}" Width="Auto" >
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeContinuousAxis ShowLabels="True"
MajorStep="{Binding Path=DataContext.MajorStep, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}"
MajorStepUnit="Minute"
LabelInterval="6"
LabelTemplate="{StaticResource axisLabelTemplate}"
PlotMode="OnTicksPadded"
Minimum="{Binding Path=DataContext.MinTime, RelativeSource={RelativeSource AncestorType=vw:CandleChartView,Mode=FindAncestor}}"
Maximum="{Binding Path=DataContext.MaxTime, RelativeSource={RelativeSource AncestorType=vw:CandleChartView,Mode=FindAncestor}}"
>
</telerik:DateTimeContinuousAxis>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis Minimum="0" Maximum="100" LabelInterval="2" />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:RadCartesianChart.Behaviors>
<telerik:ChartPanAndZoomBehavior ZoomMode="None" PanMode="Horizontal" />
</telerik:RadCartesianChart.Behaviors>
<telerik:RadCartesianChart.Series>
<telerik:CandlestickSeries x:Name="s1" ItemsSource="{Binding Path=Source}"
OpenBinding="OpenPrice"
HighBinding="HightPrice"
LowBinding="LowPrice"
CloseBinding="ClosePrice"
CategoryBinding="StartTime" >
</telerik:CandlestickSeries>
</telerik:RadCartesianChart.Series>
<telerik:RadCartesianChart.Indicators >
<!--<telerik:StochasticFastIndicator ItemsSource="{Binding Path=DataContext.Candles, RelativeSource={RelativeSource AncestorType=vw:CandleChartView, Mode=FindAncestor}}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Blue" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" />-->
<telerik:StochasticFastIndicator ItemsSource="{Binding Path=Source}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Blue" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" />
<telerik:StochasticSlowIndicator ItemsSource="{Binding Path=Source}" CategoryBinding="StartTime" CloseBinding="ClosePrice" HighBinding="HightPrice" LowBinding="LowPrice" Stroke="Red" StrokeThickness="1" MainPeriod="{Binding MainPeriod}" SignalPeriod="{Binding SignalPeriod}" SlowingPeriod="{Binding SlowingPeriod}" />
</telerik:RadCartesianChart.Indicators>
<telerik:RadCartesianChart.Annotations>
<telerik:CartesianGridLineAnnotation Value="80" Axis="{Binding ElementName=IndicatorChart, Path=VerticalAxis}" StrokeThickness="1" Stroke="Black" Label="80" />
<telerik:CartesianGridLineAnnotation Value="20" Axis="{Binding ElementName=IndicatorChart, Path=VerticalAxis}" StrokeThickness="1" Stroke="Black" Label="20" />
</telerik:RadCartesianChart.Annotations>
</telerik:RadCartesianChart>
</StackPanel>
</ControlTemplate>
<DataTemplate DataType="{x:Type models:StohasticIndicator}">
<Control Template="{StaticResource ResourceKey=StohasticIndicator}" DataContext="{Binding}" />
</DataTemplate>
---------------------
Source is ObservableCollection of Candle , and some times updates from external service.
public class Candle : INotifyPropertyChanged
{
private Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
private double _openPrice;
private double _closePrice;
private double _hightPrice;
private double _lowPrice;
private double _volume;
private DateTimeOffset _startTime;
private DateTimeOffset _endTime;
public double OpenPrice
{
get { return _openPrice; }
set
{
if (value != _openPrice)
{
_openPrice = value;
OnPropertyChanged("OpenPrice");
}
}
}
public double ClosePrice
{
get { return _closePrice; }
set
{
if(value != _closePrice)
{
_closePrice = value;
OnPropertyChanged("ClosePrice");
}
}
}
public double HightPrice
{
get { return _hightPrice; }
set
{
if (value != _hightPrice)
{
_hightPrice = value;
OnPropertyChanged("HightPrice");
}
}
}
public double LowPrice
{
get { return _lowPrice; }
set
{
if (value != _lowPrice)
{
_lowPrice = value;
OnPropertyChanged("LowPrice");
}
}
}
public double Volume
{
get { return _volume; }
set
{
if (_volume != value)
{
_volume = value;
OnPropertyChanged("Volume");
}
}
}
public DateTimeOffset StartTime
{
get { return _startTime; }
set
{
if (_startTime != value)
{
_startTime = value;
OnPropertyChanged("StartTime");
}
}
}
public DateTimeOffset EndTime
{
get { return _endTime; }
set
{
if (_endTime != value)
{
_endTime = value;
OnPropertyChanged("EndTime");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
dispatcher.BeginInvoke(DispatcherPriority.Normal,
(ThreadStart)delegate()
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
});
}
}
}
CandleSeries updates normal, but Financial indicator doesn't work. Help, please :)