Hello,
I would like to bind entity from the itemsource collection to the command parameter.
My goal is to open certain entity when it is clicked from the grid, but have unable to bind
the entity from the binded collection.
Is this possible to do by using MVVM approach?
One challenge is that I have two telerik:BarSeries defined for the chart.
So this code line at the below needs to be sorted out,
"CommandParameter="???????????????"
Here is the full code:
<telerik:RadCartesianChart Margin="10" IsHitTestVisible="True">
<telerik:RadCartesianChart.Grid>
<telerik:CartesianChartGrid MajorLinesVisibility="XY" MajorXLinesRenderMode="All">
</telerik:CartesianChartGrid>
</telerik:RadCartesianChart.Grid>
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeContinuousAxis MajorStepUnit="Minute" MajorTickStyle="{StaticResource MajorTickStyle}" PlotMode="OnTicksPadded">
<telerik:DateTimeContinuousAxis.TitleTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"></TextBlock>
</DataTemplate>
</telerik:DateTimeContinuousAxis.TitleTemplate>
</telerik:DateTimeContinuousAxis>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis Minimum="0" Maximum="200" ShowLabels="False"></telerik:LinearAxis>
</telerik:RadCartesianChart.VerticalAxis>
<telerik:BarSeries ItemsSource="{Binding EntityData1}" ValueBinding="EntityTime" CategoryBinding="EntityTakingTime" Height="1000">
<telerik:BarSeries.PointTemplate>
<DataTemplate>
<Rectangle x:Name="RectangleGreen" Fill="Green" MaxWidth="20"/>
</DataTemplate>
</telerik:BarSeries.PointTemplate>
</telerik:BarSeries>
<telerik:BarSeries ItemsSource="{Binding EntityData2}" ValueBinding="EntityTime" CategoryBinding="EntityTakingTime" Height="1000">
<telerik:BarSeries.PointTemplate>
<DataTemplate>
<Rectangle x:Name="RectangleRed" Fill="Red" MaxWidth="20"/>
</DataTemplate>
</telerik:BarSeries.PointTemplate>
</telerik:BarSeries>
<telerik:EventToCommandBehavior.EventBindings>
<telerik:EventBinding Command="{Binding OpenEntityCommand}"
EventName="MouseLeftButtonDown"
RaiseOnHandledEvents="True"
CommandParameter="???????????????" />
</telerik:EventToCommandBehavior.EventBindings>
</telerik:RadCartesianChart>
Check the attached screenshot to see the generated chart.
Green and red bars should work as links to open certain entity.
Best Regards, Tommi
I would like to bind entity from the itemsource collection to the command parameter.
My goal is to open certain entity when it is clicked from the grid, but have unable to bind
the entity from the binded collection.
Is this possible to do by using MVVM approach?
One challenge is that I have two telerik:BarSeries defined for the chart.
So this code line at the below needs to be sorted out,
"CommandParameter="???????????????"
Here is the full code:
<telerik:RadCartesianChart Margin="10" IsHitTestVisible="True">
<telerik:RadCartesianChart.Grid>
<telerik:CartesianChartGrid MajorLinesVisibility="XY" MajorXLinesRenderMode="All">
</telerik:CartesianChartGrid>
</telerik:RadCartesianChart.Grid>
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeContinuousAxis MajorStepUnit="Minute" MajorTickStyle="{StaticResource MajorTickStyle}" PlotMode="OnTicksPadded">
<telerik:DateTimeContinuousAxis.TitleTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"></TextBlock>
</DataTemplate>
</telerik:DateTimeContinuousAxis.TitleTemplate>
</telerik:DateTimeContinuousAxis>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis Minimum="0" Maximum="200" ShowLabels="False"></telerik:LinearAxis>
</telerik:RadCartesianChart.VerticalAxis>
<telerik:BarSeries ItemsSource="{Binding EntityData1}" ValueBinding="EntityTime" CategoryBinding="EntityTakingTime" Height="1000">
<telerik:BarSeries.PointTemplate>
<DataTemplate>
<Rectangle x:Name="RectangleGreen" Fill="Green" MaxWidth="20"/>
</DataTemplate>
</telerik:BarSeries.PointTemplate>
</telerik:BarSeries>
<telerik:BarSeries ItemsSource="{Binding EntityData2}" ValueBinding="EntityTime" CategoryBinding="EntityTakingTime" Height="1000">
<telerik:BarSeries.PointTemplate>
<DataTemplate>
<Rectangle x:Name="RectangleRed" Fill="Red" MaxWidth="20"/>
</DataTemplate>
</telerik:BarSeries.PointTemplate>
</telerik:BarSeries>
<telerik:EventToCommandBehavior.EventBindings>
<telerik:EventBinding Command="{Binding OpenEntityCommand}"
EventName="MouseLeftButtonDown"
RaiseOnHandledEvents="True"
CommandParameter="???????????????" />
</telerik:EventToCommandBehavior.EventBindings>
</telerik:RadCartesianChart>
Check the attached screenshot to see the generated chart.
Green and red bars should work as links to open certain entity.
Best Regards, Tommi